admin管理员组文章数量:1134587
I have a problem with an acf function for displaying an image by array.
I can get my image to work well when I upload it to the field associated with it.
On the other hand, when I don't put an image, because the field is not mandatory, I get this error warning: trying to access array offset on value of type bool
My image field is in a field group, in a page option and I'm in php 8.0
My code looks like this
<?php
$image = get_field('my_group','option');
$image_name = $image ['my_img'];
if ($image):?>
<img src="<?php echo esc_url ($image_name['url']); ?>" alt="<?php echo esc_attr($image_name['alt']); ?>" />
<?php endif;?>
本文标签: functionswarning trying to access array offset on value of type bool ACF field image group
版权声明:本文标题:functions - warning: trying to access array offset on value of type bool ACF field image group 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736780762a1952582.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论