• Resolved Newt Labs

    (@newtlabs)


    Updating from PHP7.4 to PHP8 and beyond gives the following error:

    Fatal error: Uncaught TypeError: Unsupported operand types: string / string in /wp-content/plugins/wp-video-lightbox/misc_functions.php:114

    Here is the proposed fix:

    The error message Unsupported operand types: string / string at the line $aspect_ratio = $height/$width; implies that the operation is attempting to divide two string values, which is not a valid operation in PHP.

    In the context of your wp_vid_lightbox_youtube_handler function, the $width and $height variables are being assigned values from an associative array ($atts), which are initially being passed as strings. In PHP, you cannot perform mathematical operations on strings directly without converting them to numbers.

    To fix this error, you can convert these string values to integers or floats before the division operation. Here’s how you can do this:

    Change this line:

    phpCopy code

    $aspect_ratio = $height/$width;

    to:

    phpCopy code

    $aspect_ratio = (float)$height / (float)$width;

    The (float) before $height and $width casts these variables to float numbers before the division operation is performed. This should help you eliminate the fatal error. However, you should ensure that your width and height parameters are always numeric and not zero to avoid division by zero errors.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Thank you for reaching out to us and sharing your solution. I have submitted a message to the developers to investigate further your findings.

    Kind regards.

    Plugin Author wptipsntricks

    (@wptipsntricks)

    @newtlabs, Thanks for the feedback. We have just released an update to fix the issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP8 Fix’ is closed to new replies.