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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.