Site icon Hip-Hop Website Design and Development

Fallback picture measurement when utilizing wp_get_attachment_image_src / full measurement compressed picture

I’m utilizing ACF to drag photographs utilizing ‘wp_get_attachment_image_src’ as such:

<?php $picture = wp_get_attachment_image_src(get_field('picture'), 'giant'); ?>
<img src="<?php echo $picture[0]; ?>" alt="" />

No matter picture measurement I enter (right here it’s ‘large’, however it may very well be a customized picture measurement), if the picture that has been uploaded was smaller than the set measurement, that measurement is not going to have been created and WordPress will use the complete, authentic, uncompressed picture as a fallback.

That is very undesirable, because the picture will typically haven’t any compression and be a really giant filesize unnecessarily.

What are the workarounds for this? Can I make WordPress create a full pixel-size, but jpeg compressed picture and make it use that because the fallback?

Thanks prematurely on your assist!