In the layout editor, I have an HTML field, and in that field, I have the following:
<img src="[venue]" />
That shortcode is based on a function in my functions.php file that looks like this:
function post_grid_venue() {
$venue = get_field('venue_photo');
return $venue['sizes']['venue-thumb'];
}
add_shortcode('venue', 'post_grid_venue');
Of course, the function above is referencing an ACF image object. This was working fine for about a year now, and all of a sudden, not only does it not work anymore, but it crashes my entire site. All I get is a white screen when this function is active. Do you have any idea what might be causing this? Or is there a better way to call a specific image size into the layout editor?
Welcome to our forum.
Thanks for your trying, please try following code,
function post_grid_venue() { $post_id = get_the_id(); $venue = get_field('venue_photo', $post_id); //var_dump($venue); //return ''; // For Return Value: Image URL // For Return Value: Image Object // return $venue['sizes']['venue-thumb']; if(!empty($venue['sizes']['venue-thumb'])){ return ''; }else{ return ''; } } add_shortcode('venue', 'post_grid_venue');
Under the layout editor please use only following shortcode [venue]
I hope this will solve your issue.
Regards
I have tested the code with ACF plugin, Can you please send me a temporary admin access to your site?
Please make sure image filed is "venue-thumb" correct.
Regards