简体   繁体   中英

Image attachments throwing error in new WP migration

I have a WP site that works fine in my testing environment. I migrated to a sub-directory on the clients server and now I'm having an issue with image attachments.

Fist of all, when I go to the media library, the images are all there, but the thumbnails are not showing, instead, they're replaced with a file icon. See screenshot-1 below.

Secondly, when I try to view the attachment page I'm getting the following errors:

Warning: Illegal string offset 'width' in /xxx/image.php on line 28

Warning: Illegal string offset 'height' in /xxx/image.php on line 29

Here's the code in the image.php file that is creating the issue:

$metadata = wp_get_attachment_metadata();
printf( __( 'Published <span class="entry-date"><time class="entry-date" datetime="%1$s" pubdate>%2$s</time></span> at <a href="%3$s" title="Link to full-size image">%4$s &times; %5$s</a> in <a href="%6$s" title="Return to %7$s" rel="gallery">%7$s</a>', 'detund' ),
    esc_attr( get_the_date( 'c' ) ),
    esc_html( get_the_date() ),
    wp_get_attachment_url(),
    $metadata['width'],
    $metadata['height'],
    get_permalink( $post->post_parent ),
    get_the_title( $post->post_parent )
);

Specifically, the $metadata['width'] and $metadata['height'] sections.

Because of this, functions like WP's featured image, are not working.

Has anyone come across this before, or can anyone offer a solution for this issue?

As always, any help is greatly appreciated. Thanks!

截图1

Once I had this issue with one of my client. Jetpack plugin caused the problem. Try disabling it or even disable all active plugins and check whether you still have the problem. And even check your file permissions.

Also check your image url on whether it is pointing to your new url.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM