Coder Social home page Coder Social logo

Comments (40)

Vinitvh avatar Vinitvh commented on August 10, 2024 1

@colbyfayock No issues, you can assign @anirudhprabhakaran3 this one.

from netlify-plugin-cloudinary.

Vinitvh avatar Vinitvh commented on August 10, 2024

Hi, I would like to work on this.

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

hey sure! just a heads up, if you're participating in Hacktoberfest, i might recommend creating the PR after October 1st :)

let me know if you have any questions!

from netlify-plugin-cloudinary.

Vinitvh avatar Vinitvh commented on August 10, 2024

Okay. Thank you.

from netlify-plugin-cloudinary.

Vinitvh avatar Vinitvh commented on August 10, 2024

Hi @colbyfayock I have added loading=lazy attribute to img tag. I'm not sure how do I configure netlify.toml for setting it off. Need some help here.

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

@Vinitvh here are some reasources:

And he's an example of me already using it:

You capture the value from the inputs argument passed into the build as seen in the 2nd example link.

Once there you can use it to control the change that you're making, where likely i would recommend doing something similar to this:

But I would create a separate function that does it's own processing on the HTML outside of the Cloudinary context

So something like:

  const { loadingStrategy = 'lazy' } = inputs;
  ...
  const { html, errors } = await updateHtmlImageLoading(sourceHtml, {
    loadingStrategy
  });

from netlify-plugin-cloudinary.

Vinitvh avatar Vinitvh commented on August 10, 2024

@colbyfayock Thank you. Will go through these links and submit a PR.

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

@Vinitvh sounds great. i also encourage you to take a moment to write test cases that check for both the default option and turning it off

might make sense to do that here: https://github.com/colbyfayock/netlify-plugin-cloudinary/blob/main/tests/lib/cloudinary.test.js#L87

from netlify-plugin-cloudinary.

anirudhprabhakaran3 avatar anirudhprabhakaran3 commented on August 10, 2024

Hi! Is it okay if I work on this issue? @Vinitvh are you still working on it? Thank you!

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

if @Vinitvh is no longer interested, you can work on it, but they have the first opportunity

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

sounds good, feel free to find another issue later if you have any interest!

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

Hi! @anirudhprabhakaran3 ! Just wanted to know if you are still working on it? If not, will it be Ok if I work on it?

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

since it's been 6 days since they last commented, I'm going to give them until Wednesday to respond

@Vinitvh please let use know if you plan on continuing with this ticket by Wednesday otherwise @developer-diganta gets next assignment

from netlify-plugin-cloudinary.

Vinitvh avatar Vinitvh commented on August 10, 2024

Since @anirudhprabhakaran3 was assigned, I have stopped working on this. You can assign @developer-diganta, no problem from my side.

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

Oops I got mixed up. Are you working on this @anirudhprabhakaran3?

from netlify-plugin-cloudinary.

anirudhprabhakaran3 avatar anirudhprabhakaran3 commented on August 10, 2024

Hi! Yeah, i was looking into the issue, but haven't been able to make headway... If i don't have progress by Wednesday, please assign it to someone else. Thank you!

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

@developer-diganta are you still interested in this one?

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

Yeah sure!

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

assigned :)

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

@colbyfayock Can you please help me out a bit? So I get whether the user wants lazy loading or not using const { loadingStrategy = 'lazy' } = inputs; and then inside updateHtmlImagesToCloudinary should I check the loadingStrategy and then set the attribute if required?

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

yup exactly!

if you see inside of the code, we're using getAttribute to get the src https://github.com/colbyfayock/netlify-plugin-cloudinary/blob/main/src/lib/cloudinary.js#L189

we'd want to do something similar, where we would instead want to SET the attribute based on that option

async function updateHtmlImagesToCloudinary(html, options = {}) {
  const {
    assets,
    deliveryType,
    uploadPreset,
    folder,
    localDir,
    remoteHost,
    loadingStrategy
  } = options;
$img.setAttribute('loading', loadingStrategy);

along those lines

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

also please write a test. there should be some nice examples inside of the tests file checking the HTML with the changes but lmk if you have questions about that as well

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

@colbyfayock and inside the function, I'll have to check whether loadingStrategy was true and if so, I'll set the loading attribute right?

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

well loadingStrategy in our example is set to lazy by default so you theoretically can pass that value right in to the image tag:

https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading#images_and_iframes

if someone is setting it as something else, they're explicitly saying they want something else

my thought process of using loadingStrategy instead of just loading (the attribute name) is to give opportunity to use it for other things in the future that aren't just using that tag

make sense?

so you set the attribute on the image with the value of the option

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

@colbyfayock Can you please tell how to test this (I mean run the plugin and see)?

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

once dependencies are installed you can run yarn test in the project root

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

@colbyfayock Thanks! Could you please tell me how to resolve this error?
image

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

@developer-diganta i'm not sure what changes you made that's making the URL change, this for instance would be a breaking change hence the test correctly failing

you need to look at the code changes you made to determine where the failure is and resolve it

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

@colbyfayock Is there any env file that I have to add? I think it is not able to properly form the url because of that.

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

just tried locally without an .env and it fails some tests, but the one that you showed seems to be a different issue

here is the .env:

CLOUDINARY_CLOUD_NAME="<Your>"
CLOUDINARY_API_KEY="<Your>"
CLOUDINARY_API_SECRET="<Your>"
NETLIFY_HOST="<Your>"

documentation for all but NETLIFY_HOST https://github.com/colbyfayock/netlify-plugin-cloudinary#environment-variables

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

@colbyfayock since I am adding cloudinary_cloud_name as the one that I have created from cloudinary, should I also change the tests' expect urls cloud name with the my one? And also how can I get the NETLIFY_HOST?

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

if im not mistaken the tests shoudl run with whatever keys are in the environment variables dynamically

  describe('getCloudinaryUrl', () => {

    test('should create a Cloudinary URL with delivery type of fetch from a local image', async () => {
      const { cloudinaryUrl } = await getCloudinaryUrl({
        deliveryType: 'fetch',
        path: '/images/stranger-things-dustin.jpeg',
        localDir: '/tests/images',
        remoteHost: 'https://cloudinary.netlify.app'
      });

      expect(cloudinaryUrl).toEqual(`https://res.cloudinary.com/${process.env.CLOUDINARY_CLOUD_NAME}/image/fetch/f_auto,q_auto/https://cloudinary.netlify.app/images/stranger-things-dustin.jpeg`);
    });

For instance - see how we're using a template literal to inject the environment variable in what's expected from the URL

ideally for any tests we can make them not dependent on specific variables or accounts

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

@colbyfayock there's only one test failing now which is this one
image
I tried searching why is there a 5C to the url but to no avail. I do not think that the code change could have added this since it's setting a simple attribute. And this test fails even there was no change in code since I cloned a fresh copy and the test still fails. Can this be some path related issue(computer dependent)?

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

5C is likely an encoded value

image

try checking out the main branch and running the tests. if they don't fail there, the issue is the code

definitely possible it's computer dependent though

if you're on windows, maybe the filepath is not working properly? thats something you can look into. haven't ran into this situation before with others

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

I tried with the main branch (without my code addition) and it still failed. The error was the same.

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

Shall I make PR so that you could give it a check?

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

Yup that works. Plus the tests pass on the actions environment so we can see

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

@colbyfayock I have made the PR

from netlify-plugin-cloudinary.

colbyfayock avatar colbyfayock commented on August 10, 2024

hey @developer-diganta I can close this ticket now right?

from netlify-plugin-cloudinary.

developer-diganta avatar developer-diganta commented on August 10, 2024

Yeah Sure!

from netlify-plugin-cloudinary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.