October 27, 2020 at 1:26 am
Hello Kadence-Team,
Hope you’re well.
I open a new topic because my message has probably not been seen 😉 (*Login to see link
We regularly have the following PHP Notice in our logs:
PHP Notice: Undefined variable: img in /home/public_html/wp-content/themes/virtue_premium/lib/widgets/class-kad-image-widget.php on line 87
After verification, it is not due to a conflict but to the $img variable which is not initialized (too late? or not the right var to use?) in the php class mentioned above:
if(empty($instance['image_id'])){
if(isset($instance['image_uri'])) {
echo '<img src="'.esc_url($instance['image_uri']).'" alt="'. esc_attr( $img['alt'] ) . '">';
}
} else if($size == 'custom') {
$img = virtue_get_image_array( $instance['width'], $instance['height'], true, null, null, $instance['image_id'], true );
echo '<img src="'.esc_url($img['src']).'" width="'.esc_attr($img['width']).'" height="'.esc_attr($img['height']).'" '.$img['srcset'].' class="'.esc_attr($img['class']).'" itemprop="contentUrl" alt="'.esc_attr($img['alt']).'">';
} else {
echo wp_get_attachment_image( $instance['image_id'], $size, false, array( 'alt' => $alt ) );
}
It is also possible that $img[‘alt’] should be replaced by $alt on line 87 (I did not analyze the class in detail…).
FYI: Virtue – Premium V4.9.30
Thank you in advance for the fix and have a great day.
Best Regards,
Sylvain