Comments (40)
@colbyfayock No issues, you can assign @anirudhprabhakaran3 this one.
from netlify-plugin-cloudinary.
Hi, I would like to work on this.
from netlify-plugin-cloudinary.
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.
Okay. Thank you.
from netlify-plugin-cloudinary.
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.
@Vinitvh here are some reasources:
And he's an example of me already using it:
- https://github.com/colbyfayock/netlify-plugin-cloudinary/blob/main/netlify.toml#L13
- https://github.com/colbyfayock/netlify-plugin-cloudinary/blob/main/src/index.js#L33
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.
@colbyfayock Thank you. Will go through these links and submit a PR.
from netlify-plugin-cloudinary.
@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.
Hi! Is it okay if I work on this issue? @Vinitvh are you still working on it? Thank you!
from netlify-plugin-cloudinary.
if @Vinitvh is no longer interested, you can work on it, but they have the first opportunity
from netlify-plugin-cloudinary.
sounds good, feel free to find another issue later if you have any interest!
from netlify-plugin-cloudinary.
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.
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.
Since @anirudhprabhakaran3 was assigned, I have stopped working on this. You can assign @developer-diganta, no problem from my side.
from netlify-plugin-cloudinary.
Oops I got mixed up. Are you working on this @anirudhprabhakaran3?
from netlify-plugin-cloudinary.
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.
@developer-diganta are you still interested in this one?
from netlify-plugin-cloudinary.
Yeah sure!
from netlify-plugin-cloudinary.
assigned :)
from netlify-plugin-cloudinary.
@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.
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.
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.
@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.
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.
@colbyfayock Can you please tell how to test this (I mean run the plugin and see)?
from netlify-plugin-cloudinary.
once dependencies are installed you can run yarn test
in the project root
from netlify-plugin-cloudinary.
@colbyfayock Thanks! Could you please tell me how to resolve this error?
from netlify-plugin-cloudinary.
@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.
@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.
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.
@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.
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.
@colbyfayock there's only one test failing now which is this one
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.
5C is likely an encoded value
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.
I tried with the main branch (without my code addition) and it still failed. The error was the same.
from netlify-plugin-cloudinary.
Shall I make PR so that you could give it a check?
from netlify-plugin-cloudinary.
Yup that works. Plus the tests pass on the actions environment so we can see
from netlify-plugin-cloudinary.
@colbyfayock I have made the PR
from netlify-plugin-cloudinary.
hey @developer-diganta I can close this ticket now right?
from netlify-plugin-cloudinary.
Yeah Sure!
from netlify-plugin-cloudinary.
Related Issues (20)
- [Bug] Netlify CLI local build on Windows results in Cloundinary URLs with %5C
- [Feature] Warn if cloudname configs are different
- [Feature] Add support for Netlify CDN's trasnformation syntax
- [Feature] Add support for automatic image scaling with client hints
- [Feature] Upgrade to Cloudinary Node SDK v2
- [Bug] Image does not update to a newer version
- The automated release is failing 🚨
- [Feature] Turn demo site into docs site
- [Feature] Analytics
- [Feature] Tests for onPostBuild
- [Feature] Tests for onBuild with Delivery Type of Upload
- [Bug] Duplicate requests when using Fetch API with Next.js App Router HOT 2
- [Bug] No API Key or API Secret fails builds that only need Cloud Name HOT 1
- [Feature] Add retry logic for failed uploads HOT 3
- [Bug] Host of deployed images is undefined when using fetch HOT 1
- [Feature] Upgrade project to new Netlify SDK HOT 1
- [Feature] Migrate from Jest to Vitest HOT 1
- [Bug] Production Netlify Integration Does Not Use Latest Version + Minor QOL Suggestions HOT 5
- [Bug] Failed upload errors don't get caught, leaking out of build process HOT 1
- [Bug] netlify.toml loadingStrategy is ignored
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netlify-plugin-cloudinary.