WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Uninitialized string offset error when searching for issues

[Resolved] Uninitialized string offset error when searching for issues

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jordy Meow
    Participant

    @tigroumeow

    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…

    Plugin Author Jordy Meow
    Participant

    @tigroumeow

    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;
    }

    Plugin Author Jordy Meow
    Participant

    @tigroumeow

    No need to do anything, just update the plugin to the last version and the “notices” will be gone 🙂

    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.

    Plugin Author Jordy Meow
    Participant

    @tigroumeow

    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 ^^

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Uninitialized string offset error when searching for issues’ is closed to new replies.