Next.js Image with Cloudinary - Blurred Placeholder Images Tutorial

Поделиться
HTML-код
  • Опубликовано: 10 фев 2025

Комментарии • 72

  • @colbyfayock
    @colbyfayock  6 месяцев назад

    Learn how to build a full stack Next.js app in my upcoming course: colbyfayock.com/course

  • @intoxicator7924
    @intoxicator7924 3 года назад +10

    Underrated channel, I hope you blow up! Love the Nextjs tutorials, keep it up!

  • @chickeninegg6997
    @chickeninegg6997 3 года назад +2

    Loving all of Next.js contents! Thanks and keep going!

  • @martinstanicio971
    @martinstanicio971 3 года назад +2

    Amazing video! Easy to understand, straight to the point. Keep it up!

  • @binnyzf
    @binnyzf 3 года назад

    You got a great voice for teaching, thanks for this tutorial

    • @colbyfayock
      @colbyfayock  3 года назад

      thanks, i appreciate the kind words!

  • @JamesQQuick
    @JamesQQuick 3 года назад +1

    Love Love LOVE!!!

  • @ThunderboltPath
    @ThunderboltPath 3 года назад +1

    Hey Colby, thanks for creating this tutorial! Very well structured and I love this stack. +1 sub

  • @zakwilliams490
    @zakwilliams490 3 года назад +2

    Great video. FYI, you could also simulate a 3G connection in Chrome dev tools to better show the placeholder effect.

  • @tutorialesTACHABI
    @tutorialesTACHABI 3 года назад +1

    This guy is crazy! Loving all the videos keep up the good work ly

  • @alexgv99
    @alexgv99 3 года назад +1

    Hi Colby... thank you for the video, great as always... I'm wondering why didn't you set the throttling in the network tab of dev tools to slow network, instead of simulate the delay...

    • @colbyfayock
      @colbyfayock  3 года назад

      that... is a great question! didn't think about that as i was making the video haha. ive been meaning to make some videos about dev tools too!

  • @mahbubhasan1538
    @mahbubhasan1538 3 года назад

    Thanks man. I amy trying it from 10 hour but can't do it. your video help me to do that in 10 minutes. Take love ❤❤❤

  • @colbyfayock
    @colbyfayock  Год назад

    Get fresh tutorials and other free content straight to your inbox! colbyfayock.com/news

  • @ThiagoFranchin
    @ThiagoFranchin 3 года назад +1

    Thanks....🤩

  • @paulmckenna5799
    @paulmckenna5799 3 года назад

    Great tutorial - really appreciate it.
    Am I right in thinking that the paddingTop ratio only works because the {styles.card} is providing width and height? In a blog post for example, the paddingTop % will be relative to the entire page.

    • @colbyfayock
      @colbyfayock  3 года назад +1

      if im not mistaken the padding top is relative to the parent, so when you set width to 100% and height to 0 then using a % for the padding top based on the ratio you want to use, it will basically take the current width into consideration when building that ratio to give you a height!

  • @59140Dunkerque
    @59140Dunkerque 3 года назад +1

    masterclass

  • @thecutedreamkostasp.4449
    @thecutedreamkostasp.4449 2 года назад

    I have no idea why u have so much low subs and views! Thats so unfair! Thx for all your work! I have a question about Image! Do images are statically generated at build time so on production u see them immediately and not take time to load on view for a bad experience? Ty in advance !

    • @colbyfayock
      @colbyfayock  2 года назад

      thanks for the kind words :) the first time images from Cloudinary are loaded they'll have a bit of processing time, but every time after they're served from cache (unless the cache is cleared). you can alternatively use transformations on upload: cloudinary.com/documentation/transformations_on_upload

  • @fabriciofeitosadecastro3170
    @fabriciofeitosadecastro3170 2 года назад

    thank you

  • @JustinAvery
    @JustinAvery 3 года назад

    Thanks for the tutorial. How would this work if you're using the /fetch/ method for cloudinary?

    • @colbyfayock
      @colbyfayock  3 года назад

      im actually not totally sure what the difference is. would fetch happen in the browser or something?

  • @stillonholliday
    @stillonholliday 2 года назад

    Hi Colby - is there anywhere that describes the benefits of using next/image with Cloudinary? They seem to have overlapping functions (e.g. resizing and compression). Also are there places not to use next/image? e.g. on a locally stored svg icon that doesn't need to compressed or responsively sized. A best practice guide would be great for these topics.

    • @colbyfayock
      @colbyfayock  2 года назад

      hey good question! I don't have anything comprehensive, but you're right, there is definitely a little bit of cross-over. beyond the crossover though Cloudinary provides a ton of out-of-the-box features on top of that like transformations, overlays, and such. but yeah a best practice guide would definitely be a great idea to put together

    • @stillonholliday
      @stillonholliday 2 года назад

      ​@@colbyfayock it would be a great white paper or podcast. I have an example image heavy travel site if you need (with Strapi)! Its not that one is better than the other. It just how best to effectively use both together. I feel there are a lot of developers don't know when to use Cloudinary, next/image and img - my pseudo technical viewpoint is there needs guidelines to achieve code simplicity and highest performance.

    • @colbyfayock
      @colbyfayock  2 года назад +1

      @@stillonholliday yeah absolutely. its definitely a good talking point in the Next.js X Cloudinary integration world. the Next.js Image component does a lot of great stuff when you're not dealing with Cloudianry but I personally use Cloudinary URLs directly as at that point, you're somewhat mixing and doubling the work
      for instance, a simple with auto optimization and auto formatting will provide all the necessary benefits backed by Cloudinarys extensive CDN, then on top, you get a ton of additional options, so it becomes unnecessary to use the Next.js Image component unless you're trying to take advantage of other features
      i think though we as cloudinary can do a better job at providing more of those options, ive been considering how i can improve the Next.js / Cloudinary integration, such as a custom loader that provides more capabilities than the baked-in cloudinary loader, but thats a separate topic
      are you able to mention the site you work on? just curious :) but undersatnd if you can't publicly

  • @BarryDocherty
    @BarryDocherty 2 года назад

    I'm getting a 404... if i put in full url, all is ok but get a 404 if I just parse the filename. Maybe I missed something. Wouldn't I have to set the Cloud address somewhere in the code to reference?

    • @BarryDocherty
      @BarryDocherty 2 года назад

      Never mind. Image was in a sub directory on cloudinary. Works.

    • @BarryDocherty
      @BarryDocherty 2 года назад

      But I'm going to want to automate the page population of images, which I did on the site I built a couple of years ago. Not sure how I can implement that script in Next.jS. Basically i will want to fill a directory with a bunch of images and the script would read that directory and populate the page with all its content.

    • @BarryDocherty
      @BarryDocherty 2 года назад

      this is cool, but one thing that bothers me, is now that the image name is dynamic, that won't work for me when I want to automatically populate a page of the entire directory contents of images. I don't want to have to key in 30+ image sources. Current site my client has, this feature is incorporated, but it's old 2016 web tech.

    • @colbyfayock
      @colbyfayock  2 года назад +1

      @@BarryDocherty RE: listing images, check this out: ruclips.net/video/XJWdLbw3QjY/видео.html

    • @rahil_lakhani
      @rahil_lakhani 2 года назад

      Hello @@BarryDocherty ,
      I am also getting this error & my images are there in the Sub Directory on Cloudinary. I have been searching for the resolution since an hour now & couldn't find any. Could you please share the solution?

  • @Justanothersakshi
    @Justanothersakshi 3 года назад

    Hey just wanted to confirm does Cloudinary work with "build": "next build && next export" in json file?

    • @colbyfayock
      @colbyfayock  3 года назад

      hey! with my tutorial "as is" you wouldn't be able to do it as Next.js requires Next Image at request time. there may be options for creating a custom loader to do this though

    • @Justanothersakshi
      @Justanothersakshi 3 года назад

      @@colbyfayock can't we use a normal html img tag in nextjs or is it necessary to use image optimization !? Because my project is SSG based so have probelm with next/img and I don't want to use any image loader.

    • @colbyfayock
      @colbyfayock  3 года назад

      @@Justanothersakshi Next.js Image component is completely optional!! feel free to use the standard

    • @Justanothersakshi
      @Justanothersakshi 3 года назад

      @@colbyfayock so the html component won't give me problem even if I have "build": "next build && next export". And also Can i use images from the public folder using normal img tag right that won't give me problem while deploying later?

    • @colbyfayock
      @colbyfayock  3 года назад

      @@Justanothersakshi correct! if you had an image in /public/image.jpg, you would do and it should work perfectly

  • @panjigumelar3082
    @panjigumelar3082 3 года назад

    cool man, please add how to upload images to cloudinary with nextjs :)

    • @colbyfayock
      @colbyfayock  3 года назад

      nice idea! do you mean like an upload form where someone can select an image then upload it?

    • @panjigumelar3082
      @panjigumelar3082 3 года назад +1

      @@colbyfayock yes, that's what I mean, thanks 😊

  • @MilanDrazic
    @MilanDrazic 3 года назад

    Hi
    How to show img when is in src folder, with relative path?

    • @colbyfayock
      @colbyfayock  3 года назад

      have you tried importing it? import myImage from '../path' then set the image source as that

    • @colbyfayock
      @colbyfayock  3 года назад +1

      you might need this: github.com/twopluszero/next-images

    • @MilanDrazic
      @MilanDrazic 3 года назад

      @@colbyfayock yes that's it. Yes I try import. Now working with require
      Nice 👍

  • @qasim8
    @qasim8 3 года назад +1

    Thats a neat trick with the aspect ratio sizing, i've used that in the past and is a real time saver however you can do that natively with css web.dev/aspect-ratio/

    • @colbyfayock
      @colbyfayock  3 года назад

      nice! thanks ill have to check that out

  • @z1982_
    @z1982_ Год назад

    what about the place holder blur data URL props...?

    • @colbyfayock
      @colbyfayock  Год назад +1

      The challenging thing about the blurred placeholder is you need to pass in the data URI. That's not something you'd want to do in tbe client. With react server components there are potential options for that that make it easier. In previous next versions you could build those in your data fetching method but it's not as straightforward. There's a library called blurhash that works well for that. You can use cloudinary but blurhash is a great option without the network request

    • @z1982_
      @z1982_ Год назад

      @@colbyfayock thanks a lot very interesting. Why not doing it in the client? At the end, we are not revealing any kind of API key or something right ?

    • @colbyfayock
      @colbyfayock  Год назад +1

      @@z1982_ if the image is a remote file, youd have to download it in the client, then transform it to a blurred version, which defeats the purpose. if it's a local file, imt not sure if that would be performant or if you would have much luck doing it with browser APIs

    • @z1982_
      @z1982_ Год назад

      @@colbyfayock thanks a lot, I got your point on the useless additional transformation. However, when used with an image provider that offers url based transformation API like cloudinary you can request a much smaller version of your asset to be blurred and a proper version as a src
      What do you think?

    • @colbyfayock
      @colbyfayock  Год назад +1

      @@z1982_ definitely! But as far as i know, the newer API for the Next.js Image component doesn't support using URLs, you must pass data URLs nextjs.org/docs/pages/api-reference/components/image#blurdataurl

  • @aryanvikash1967
    @aryanvikash1967 3 года назад

    So basically there is no option for wildcard permission for random domain names in some case we add a random image source in database and load it in nextjs app , so we can't do that again we have to add those image domain in config file and build it
    Like insted of array they should allow us to use * 😝

    • @colbyfayock
      @colbyfayock  3 года назад

      ah yeah that's a bummer, i haven't ran into that situation yet, seems like something that they should support. have you tried making an issue on their repo?