WordPress.org

Ready to get started?Download WordPress

Forums

WP Retina 2x
[resolved] Uninitialized string offset error when searching for issues (6 posts)

  1. jwarren
    Member
    Posted 1 year ago #

    I'm using WP 3.5 and WP-Retina 0.8.

    On the WP-Retina page, when I search for issues, I receive the following error message (several times)

    Notice: Uninitialized string offset: 0 in /home/mywebsite/www.mywebsiteaddress.placeholder/www/wp-content/plugins/wp-retina-2x/wp-retina-2x.php on line 219

    The relevant line is:

    $original_width = $meta['width'];

    http://wordpress.org/extend/plugins/wp-retina-2x/

  2. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    Hey jwarren,

    This is strange because only the images are sent through this function, and they must have a width and height, except if of course if something is broken.

    I tried to reproduced this issue but I can't.

    Can you do something for me? Modify the "function wr2x_retina_info( $id )" and after the line "$meta = wp_get_attachment_metadata($id);", please add:

    if ( !isset( $meta['width'] ) ) {
    print_r( $meta );
    return $result;
    }

    We will then get more information instead of that notice. Please share your findings with me. I am not sure it's a problem linked to the Retina plugin...

  3. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    Okay, I could reproduce the issue : I took random files (PSD, TXT, DOC, PDF...) and change their extension to an image extension, then I got exactly the same issue as yours.

    It shouldn't occur though, I think some of your media either have an incorrect extension, or their WordPress metadata has been erased (how? I have no idea... maybe a plugin does that? still strange).

    I updated the code of the plugin to ignore those files so the warnings or notices will not appear anymore. If you want the code to be updated, forget the previous code I gave you and use this one instead:

    if ( !isset( $meta, $meta['width'], $meta['height'] ) ) {
    return $result;
    }

  4. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    No need to do anything, just update the plugin to the last version and the "notices" will be gone :)

  5. jwarren
    Member
    Posted 1 year ago #

    Jordy, thank you very much! You're a star. Btw, is there any idea of how to identify which files are malformed? We have approx 500 images in this site, so can't realistically go through one by one.

  6. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    Maybe there is a way to do it using a plugin which has this purpose? I have no idea if there is one...

    Anyway, you can change the code of the plugin so that it will display those attachment.

    Look at the wp-retina-2x.php file, go to to the line 220 and change this:
    if ( !isset( $meta, $meta['width'], $meta['height'] ) ) {
    return $result;
    }

    to this:

    if ( !isset( $meta, $meta['width'], $meta['height'] ) ) {
    echo "Attachment " . $id . "
    " .
    return $result;
    }

    Try it, then it should display links to the attachments with issues.

    By the way, thanks for rating my plugin if you like it ^^

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic