Interfacelab / ilab-media-tools

https://mediacloud.press/
GNU General Public License v3.0
114 stars 37 forks source link

Show Embed video in client #234

Open huysynf opened 4 months ago

huysynf commented 4 months ago

When I embed video use button Add media cloud video and save. In client it show error

Notice: Trying to get property 'width' of non-object in /var/www/wp-content/plugins/ilab-media-tools/classes/Tools/Video/Player/VideoPlayerShortcode.php on line 99

So I try to fixed and find code not working in file VideoPlayerShortcode.php line 99 Code in plugin

if ( empty($asset) ) {
            $width = intval( arrayPath( $meta, 'width', (int) 0 ) );
            $height = intval( arrayPath( $meta, 'height', (int) 0 ) );
            if ( !empty($width) && !empty($height) ) {
                // error in here
                $extras .= " width={$asset->width} height={$asset->height}";
            }
        } else {
            $extras .= " width={$asset->width} height={$asset->height}";
        }

====> may be change to fixed it

if ( empty($asset) ) {
            $width = intval( arrayPath( $meta, 'width', (int) 0 ) );
            $height = intval( arrayPath( $meta, 'height', (int) 0 ) );
            if ( !empty($width) && !empty($height) ) {
                $extras .= " width={$width} height={$height}";
            }
        } else {
            $extras .= " width={$asset->width} height={$asset->height}";
        }