• codeGlaze

    (@codeglaze)


    PHP Warning:  Illegal string offset 'width' in [..]/wp-content/plugins/responsify-wp/includes/create_responsive_image.php on line 60
    PHP Warning:  Illegal string offset 'height' in [..]/wp-content/plugins/responsify-wp/includes/create_responsive_image.php on line 61

    Just noticed this today while I was debugging some new code on a site.
    It doesn’t look to be affecting functionality at the moment.

    https://wordpress.org/plugins/responsify-wp/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author stefanledin

    (@stefanledin)

    Hi codeGlaze!
    I think I’ve seen this error in another thread. Do you have a very small image somewhere? It might be that image that is causing the error.

    Yeah, I’ve had those too (we’ve discussed it earlier).
    Thought they were gone, but indeed it’s still firing those warnings.
    Strange thing is it only occurs on our prod server (php-cgi), not on local dev (php-cgi or mod) …

    Plugin Author stefanledin

    (@stefanledin)

    Okey. I really don’t know where to start with this. Which PHP version are you guys using? Is the warnings printed on all pages? Is there many errors, one per image?

    Hi !
    Well I’ve been in touch with our hosting, and I put this on a side note, to see if they can think about something.
    I tried everything here, several versions of PHP (from 5.4 to 5.6), module and CGI (on MAMP) and no errors are thrown (console logs or with WP_Debug on). This only occurs on the prod server and I think only one time for each parameter ‘height’ and ‘width’.

    Sadly, the errors are not precise enough to let me know which images are concerned.

    Hi !
    I got back on these errors and weeks after, there still here.

    Looking at the logs, It seems the error is just sent 1 time, I mean one time per visit, 1 error for the width and one for the height. But impossible to tell which image do this… one sure thing we don’t have small image, as you suggested earlier.

    After checking the plugin code, and the exact lines mentioned (always the same), I decided to put an if (isset(…)) around the array declared here. And it seems to have stopped the errors, without breaking functionality.

    In create_responsive_image.php, line 55 :

    if ( isset($image_meta_data['width']) && isset($image_meta_data['height']) ) {
        $image_meta_data['sizes']['full'] = array(
            'width' => $image_meta_data['width'],
            'height' => $image_meta_data['height']
        );
    }

    I don’t know why, but it seems that the images don’t always have image and width referenced for the ‘full’ size.
    So wait and see.

    Sorry, I meant : it seems that the images don’t always have HEIGHT and width referenced for the ‘full’ size. 😉

    Plugin Author stefanledin

    (@stefanledin)

    I see. Well this is interesting behaviour! But if this is the solution for you, I’m glad to add it in the next release. RWP 1.9 is a huge update and I’ve been working on it many weeks now, so I hope I can release it soon 🙂
    Thanks for investigating 😉

    Hi stefan,
    have you come across those errors now ?
    They’re still filling pages on my logs, and I don’t if it’s affecting the site perfs or not.

    I don’t really have clues about what happens but it seems though, that there’s only one error thrown for each page AND it also seems that the debug don’t print comment for the first image using Responsify WP… but as it doesn’t print info I can’t tell you more on this…

    Plugin Author stefanledin

    (@stefanledin)

    Nope, I still haven’t seen this myself.
    If there’s no debug comments, RWP hasn’t been able to do anything with the image. It usually means that RWP couldn’t find the image ID in the database.
    What theme are you using? Is it anything you can send me so I can try it out?

    Hi ! We use our own-coded theme, and unfortunately I can’t send it here…
    But you’re pointing me to a good direction, it seems something prevent RWP from getting the correct ID… I’ll check functions.php to see if something here could interfere.

    But still, the image is loaded. So there’s a fallback if RWP fails ? Or might the problem be elsewhere ?

    Plugin Author stefanledin

    (@stefanledin)

    If RWP can’t do something with the image, it just leaves it in the way WordPress prints it from the beginning.
    RWP takes the image URL and searches for it in the database and gets the ID. I’ve seen issues in the past with the location of the uploads folder. Is there any difference between the URLs of the images that does work vs the one that doesn’t?

    No, apparently not.
    But we have a special config for FTP, don’t know if there’s an impact. We also use Cloudflare, maybe it can be something with the url rewriting at some point ?

    I’ve checked again for the URLs, and I see that some debug info are completely missing while RWP have done it’s job and outputted the img tag. Especially inside the_content.

    Also, I’m still using the old fashion call to RWP (Picture::create), do you advise me to change it to the “rwp_img();” function ?

    Thx for your support !

    Plugin Author stefanledin

    (@stefanledin)

    Okey, yeah I definitely suspect that the URL rewriting may have something to do with it. Have you tried if the native implementation of responsive images (from WP 4.4) works?

    No, you’ll be fine using Picture::create(). rwp_img() is actually calling Picture::create under the hood 😉

    No ! I did not. I’ll try that and see what it returns.

    mmmh…
    I had to deactivate RWP to make it work, but the native implementation works.
    Except that it’s not returning (as RWP do) the ‘http:’ prefix in the URL, it begins with the “//”.
    Can it be some hint for us ?

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘Illegal string offset warning’ is closed to new replies.