Hi anyway!
Thanks for being a user 🙂
The code looks fine to me. What does it output? A regular <img>or is it a <picture> element?
Have you tried turning on the debug mode?
Are you sure the images is available in those sizes?
Thread Starter
anyway
(@sfdsfwer)
Hi Stefan,
thanks for the quick reply!
> The code looks fine to me. What does it output? A regular <img>or is it a <picture> element?
I testet both, and both didn’t work.
> Have you tried turning on the debug mode?
Yes today I did, but there is no error message.
> Are you sure the images is available in those sizes?
Yes, the images are there, the srcset isn’t available.
But good to know that I’m using the right codesnippet. I’ll test a little more, next days. Out of the box, the plugin is working pretty fine, it’s just because the custom sizes.
Thank you for your time!
There won’t be any error messages, just HTML comments above each image in the source. If there’s nothing there with the debug mode turned on, RWP wasn’t able to do anything with the images.
Thread Starter
anyway
(@sfdsfwer)
Hi Stefan,
thanks for coming back to my post. In the meantime I experimented a bit with hardcoding the picture element, and it seems to work fine, so far:
<picture>
<img
sizes="(max-width: 414px) 100vw, (max-width: 768px) 100vw, (max-width: 1600px) 100vw, 100vw"
srcset="
<?php echo get_the_post_thumbnail_url($post_id, 'headerpic-small'); ?> 415w,
<?php echo get_the_post_thumbnail_url($post_id, 'headerpic-medium'); ?> 768w,
<?php echo get_the_post_thumbnail_url($post_id, 'headerpic-large'); ?> 1200w"
src="<?php echo get_the_post_thumbnail_url($post_id, 'headerpic-large'); ?>"
alt="Headerimage">
</picture>
This of course has nothing to do with your plugin and besides, I’m not sure if that really should be done that way. Anyway, the expected images appearing now.