When using get_field(‘image_gallery’) with the gallery add-on causes a huge performance slow down. Especially when displaying many galleries on the same page from different posts. The only work around was to use a custom sql statement to target specific gallery. We believe the issues is the serialization of the data. It would be convenient to use get_field as documented.
$sql = "select meta_value from wp_postmeta where post_id='".$post_id."' and meta_key='image_gallery' ";
$result = mysql_query($sql);
if (!mysql_num_rows($result)) {return;}
$row = mysql_fetch_array($result);
$val = $row[0];
$imageArray = unserialize($val);
And call the image(s) like this:
foreach($imageArray as $img):
$imageURL = wp_get_attachment_image_src($img,'IMAGE SIZE');
echo '<image src="'.$imageURL.'" />';
endforeach;
Hi @Jason Prescher
It is possible to load the DB value WITHOUT any formatting like so:
$ids = get_field('image_gallery');
You can then loop over these ID’s and do as you wish.
Thanks
E