• After the last upgrade to v3.3.0 my WordPress installation returns the following error:
    Uncaught TypeError: Unsupported operand types: string - int in top-10/includes/frontend/class-media-handler.php:586

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ajay

    (@ajay)

    Please can you tell me which version of PHP are you using?

    Also, is this via the Top 10 widget? If so, can you please save the widget again via Appearances / Widget?

    It looks like one of the items in that line are being pulled as a string but the functions need an int.

    There might be a quick fix for that is to change these lines or we might have to do something else.

    $size_width = absint( $size_info['width'] );

    $size_height = absint( $size_info['height'] );

    Thread Starter Stelios

    (@djstelios)

    My PHP version is 8.1 The same error occurred when I downgraded the server’s PHP version to 8.0
    Yes, it’s via the widget. Unfortunately, I couldn’t save again the Widget because the exact same error occurs when I’m trying to access the Widgets settings.
    A workaround for this was to change, not the lines you mentioned, but the line 586 as follows:
    $distance = sqrt( pow( absint($thumb_width) - $size_width, 2 ) + pow( absint($thumb_height) - $size_height, 2 ) );
    Then, save the Top 10 plugins settings, revert the line 586 to the previous state and everything now working fine, except…

    Now, the plugin does not take into consideration the selected “Thumbnail size” option. Always shows the 150×150 image. In order to make it work, I had to manually enter the thumbnail sizes at the “Thumbnail width” and “Thumbnail height” text input

    • This reply was modified 1 year, 8 months ago by Stelios.
    • This reply was modified 1 year, 8 months ago by Stelios.
    Plugin Author Ajay

    (@ajay)

    Is this happening for a specific post or all of them? I had to introduce this new function to guess the nearest thumbnail size when a width and height are provided.

    I have a feeling what’s happening now is that with the absint of the thumb width and height for this image, it’s converting the string to 0 which is then only able to guess the 150x which is the default thumbnail in settings.

    When you say manually set the text inputs is that in the widget? And, with was blank it had an issue?

    Thread Starter Stelios

    (@djstelios)

    I don’t know if the problem occurs for specific post, or all of them. I use just one widget, but I never change the widget width/height settings. Because the dimensions are site-wide, I change them on the plugin’s settings. There, no matter, what selection I made at the “Thumbnail size” option, always the 150×150 image is selected. The only workaround is to change the width/height with the desired ones, at the plugin’s settings.

    For example, at the following screenshot, if wprm-metadata-16_9 (480×270) is selected, but the Thumbnail width/height are empty, always the 150×150 is selected. As soon as I enter the desired values at these fields, the image is displayed correctly.

    Also I always have selected the option “No width or height set. You will need to use external styles to force any width or height of your choice.” because I need to control the dimensions.

    Please, keep in mind, that I have reverted the line 586 at it’s original code after I saved the plugin’s settings. The code, now, is:
    $distance = sqrt( pow( $thumb_width - $size_width, 2 ) + pow( $thumb_height - $size_height, 2 ) );

    • This reply was modified 1 year, 8 months ago by Stelios.
    Plugin Author Ajay

    (@ajay)

    @djstelios

    Perfectly clear now. I didn’t realise that you had the thumbnail width and height on this page blank. To be frank I need to put some checks in there to force it in the future if it is blank.

    The reason being is that these are the fallback width and height when you don’t have any specified in the widget and what’s happened right now is that if you have that empty in the widget it’s been pulling a blank string and the result is that you have the error.

    In terms of the no width/height set, that just controls the img tag attributes.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP Error after upgrade to 3.3.0’ is closed to new replies.