Home › Forums › General Issues › Problem delivering retina images via data-src attribute › Reply To: Problem delivering retina images via data-src attribute
In typical fashion, I got there in the end! This is what I ended up using in my template files:
<?php $image = get_field('field_name'); ?> <img src="<?php echo get_template_directory_uri(); ?>/images/loader.gif" alt="" data-src="<?php $image = get_field('field_name'); echo($image['sizes']['custom-size']); ?>" data-src-retina="<?php $image = get_field('field_name'); echo($image['sizes']['custom-size-retina']); ?>" />
And to the functions.php with these declarations:
add_image_size( 'custom-size', 300, 300, true ); // Standard pixel density add_image_size( 'custom-size-retina', 600, 600, true ); // Double pixel density
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.