RICG Responsive Images – Does this work with ACF plugin?
-
I am currently using the Picturefill.WP 2 plugin by Kyle Reicks to work with custom image fields created using the Advanced Custom Fields plugin by Elliot Condon.
I thought I would see if this can just be a straight swap to activate the Responsive Images plugin, but if I do, my site completely breaks. Then I remembered following specific instructions to get the plugin to work with custom image fields. The ACF image field is used to create a custom hero image that the client can easily change on each page. Pages without the ‘hero image’ set do work, and images applied to the content box using the media uploader work fine. So I think it is safe to say that the reason for the broken site is the ACF image field which shows no content after the placement of the ACF image.
The code I currently use is as follows:
On template page.php file –
<?php if (get_field('my_custom_image') != '') { $image_object = get_field('my_custom_image'); $image_output = '<img src="' . $image_object['sizes']['medium'] . '" alt="' . $image_object['alt'] . '" />'; echo apply_filters('theme_acf_image', $image_output, 'my_custom_image'); } ?>
On functions.php file –
/* * Enable support for PicturefillWP 2 plugin with ACF plugin. * */ add_filter('theme_acf_image', 'theme_function_for_acf_image', 10, 2); function theme_function_for_acf_image($content, $name_of_the_image_field){ return Picturefill_WP::get_instance()->cache_picturefill_output($content, $name_of_the_image_field); }
Now my scripting knowledge is virtually non existent, I can follow instruction and hack to a very limited extent, but don’t have a clue how to work out if this can be made compatible with the RICG Responsive Images plugin, and couldn’t see any in depth documentation or example that may help. So I would be very grateful for some help or advice.
- The topic ‘RICG Responsive Images – Does this work with ACF plugin?’ is closed to new replies.