Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funzeye/f48f7363ac9aeaa1e618 to your computer and use it in GitHub Desktop.
Save funzeye/f48f7363ac9aeaa1e618 to your computer and use it in GitHub Desktop.
How To Use Responsive Images in WordPress using Advanced Custom Field's image field and the wp-tevko-responsive-images Plugin
<figure>
<?php
$image = get_field('your_image_field_name');
$atts = array(
'imageid' => $image,
'size1' => '0',
'size2' =>'600',
'size3' =>'1000'
);
echo tevkori_responsive_shortcode($atts) ; ?>
<figcaption><?php echo get_cat_name($value); ?></figcaption>
</figure>
@funzeye
Copy link
Author

funzeye commented May 31, 2014

This is the code I use in conjunction with the

  1. Advanced Custom Fields WordPress plugin - http://www.advancedcustomfields.com/
  2. The tevko responsive image plugin - https://github.com/tevko/wp-tevko-responsive-images

You will need to create an image field in ACF and be sure to set the 'return value' to Image ID.

(You can ignore the figure elements above, just left them in there to help give some context to the important code - from lines 3 to 10)

Some background on the tevko responsive image plugin: http://css-tricks.com/hassle-free-responsive-images-for-wordpress/#comment-1581891
Note that in this article Chris uses the old version of Picturefill, while the Tevko plugin now uses the Picturefill 2.0 code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment