0

So i've been following this advanced Wordpress Theme dev tutorial Wp Tutorial

And all good but i'm seeing in that particular video that in the end he inspect with the browser and get an image with a srcset property

Image with src prop

However, when i use the exact same code is not working for me. I literally cloned this guy's tutorial code (although i'm writing mine while i take the course to study) and i got the same error. Also, if i go to wp-content/uploads i only see one version of my uploaded image, when i should have default WP sizes (thumbnail, medium, large, etc)

I wonder if something happened with WP 5.7 or newer versions and srcset won't pop up as a prop anymore or i'm doing something wrong.

This is The repository i'm using while i take the course so anyone can check it out and find out what's happening.

My desire is to be able to see multiple uploaded versions of any image inside wordpress and to be able to see srcset property in my img tags on the frontend.

To find out this error i simply did the_post_thumbnail('thumbnail') and got this

<img width="233" height="233" src="http://localhost/aquila/wp-content/uploads/2021/04/el_bochinche_pars.jpeg" class="w-100" alt="" loading="lazy" sizes="(max-width: 350px) 350px, 233px">

No srcset for multiple img versions or anything.

Thank you!

Frank Ponte
  • 135
  • 1
  • 11
  • The image you are using is probably too small for WordPress to generate additional sizes. If there are no additional sizes, there is no need for a srcset – Zencode.dk Apr 17 '21 at 12:00
  • Hey man, thank you for sharing your knowledge! My image is 1080x1080 so i think it's huge if you're using it for a, let's say, a post featured image. I'd like WP to generate a 150x150 instead but sadly that's not happening. @Zencode.dk – Frank Ponte Apr 19 '21 at 03:58
  • That does sound strange indeed. You could take some other steps in debugging though. Does this happen on a clean WP install with no plugins too? If so, it is probably a problem with your theme or a plugin that has some undesired functionality. If not, I would check if the host supports imagemagick/gd2 to ensure WP is able to process the image resizing etc. – Zencode.dk Apr 20 '21 at 04:50

0 Answers0