Warning: getimagesize() expects parameter 1 to be string
-
Hi all,
after the last update of Yoast SEO, I’m getting the following error at the top of my page: Warning: getimagesize() expects parameter 1 to be string, array given in /home/infoioej/public_html/wp-content/themes/newsanchor/functions.php on line 22
I opened functions.php and like 22 is:$size = getimagesize($img_src);
The whole part is as follows:
/**
* Temporary fix
* OpenGraph add a og:image:width and og:image:height for FB async load of og:image issues
*
* https://github.com/Yoast/wordpress-seo/issues/2151
* https://developers.facebook.com/docs/sharing/webmasters/optimizing#cachingimages
*/
if(class_exists(‘WPSEO_OpenGraph_Image’)) {
add_filter(“wpseo_opengraph”, function () {
global $wpseo_og;// will get a array with images
$opengraph_images = new WPSEO_OpenGraph_Image( $wpseo_og->options );foreach ( $opengraph_images->get_images() as $img ) {
// this block of code will first convert url of image to local path
// for faster process of image sizes later
$upload_dir = wp_upload_dir();
$img_src = str_replace($upload_dir[‘url’], $upload_dir[‘path’], $img);
$size = getimagesize($img_src);// display of this tags with Yoast SEO plugin
$wpseo_og->og_tag( ‘og:image:width’, $size[0] );
$wpseo_og->og_tag( ‘og:image:height’, $size[1] );
}}, 32);
}Can you please advise on how to fix this annoying error?
Thanks in advance
The page I need help with: [log in to see the link]
The topic ‘Warning: getimagesize() expects parameter 1 to be string’ is closed to new replies.