Plugin Directory

Changeset 2255308


Ignore:
Timestamp:
03/05/2020 10:25:10 PM (6 years ago)
Author:
team-ok
Message:

Fixed non-numeric value encountered-warning

Location:
switch-video-quality/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • switch-video-quality/trunk/readme.txt

    r2093280 r2255308  
    44Tags: change, choose, select, quality, resolution, self-hosted, video, stream, player, wordpress, media, library, playlist, responsive, embed, iframe, bitrate, HD, 4K, html5, mediaelement, mejs, svq
    55Requires at least: 3.6
    6 Tested up to: 5.2.1
    7 Stable tag: 1.5.1
     6Tested up to: 5.3.2
     7Stable tag: 1.5.2
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    2828
    2929= How to use: =
    30 * In the post editor, use the normal video shortcode (width and height set to your needs) to place the video player in your content area, like this:
     30* In the post editor, use the normal video shortcode (width and height set to your needs) to place the video player in your content area, like this: 
    3131`[video width="1024" height="576"]`
    3232* There are no other shortcode attributes necessary (actually even width and height aren't necessary as they default to 640 x 480 px when they are omitted), but you may add a src and a poster attribute to ensure normal shortcode functionality when Switch Video Quality is not used or deactivated.
     
    187187* Fixed subtitle error related to WP 5.0 saving empty required input fields
    188188* CSS fixes (HD and 4K labels)
     189= 1.5.2 =
     190* Fixed the "A non-numeric value encountered"-warning (only PHP >= 7.1) that was displayed when using shortcode attributes with non-numeric values where numeric values were expected.
  • switch-video-quality/trunk/switch_video_quality.php

    r2003622 r2255308  
    33Plugin Name: Switch Video Quality
    44Description: Switch Video Quality adds quality switch functionality to the wordpress video player to let you choose between different resolutions of a (self-hosted) html5-compatible video.
    5 Version: 1.5.1
     5Version: 1.5.2
    66Author: Timo Klemm (team-ok)
    77Text Domain: switch-video-quality
     
    2626}
    2727//Switch Video Quality Version Number
    28 define( 'SVQ_VERSION', '1.5.1' );
     28define( 'SVQ_VERSION', '1.5.2' );
    2929
    3030add_action( 'load-post.php', 'switch_video_quality_settings' );
     
    437437        // if the height attribute is missing, set it automatically (assuming the video has a 16:9 aspect ratio)
    438438        if ( empty($atts['height']) ){
    439             $atts['height'] = round($atts['width'] * 0.5625);
     439            $atts['height'] = round( (int) $atts['width'] * 0.5625);
    440440        }
    441441
    442442        // if the video is bigger than the theme
    443         if ( !$is_svq_embed && !empty( $content_width ) && $atts['width'] > $content_width ) {
    444             $atts['height'] = round( ( $atts['height'] * $content_width ) / $atts['width'] );
    445             $atts['width'] = $content_width;
     443        if ( !$is_svq_embed && !empty( $content_width ) && (int) $atts['width'] > (int) $content_width ) {
     444            $atts['height'] = round( ( (int) $atts['height'] * (int) $content_width ) / (int) $atts['width'] );
     445            $atts['width'] = (int) $content_width;
    446446        }
    447447        // find the quality that is closest to the player's height, but not smaller than it (to avoid upscaling)
    448448        // and set it as default
    449449        foreach ($svq_stored_metadata as &$svq){
    450             $reference = ($def_qual !== null ? absint($def_qual) : $atts['height']);
     450            $reference = ($def_qual !== null ? absint( $def_qual ) : $atts['height']);
    451451            $init_qual = null;
    452452            $init_index = 0;
     
    461461                    if ($init_qual === null
    462462                        // or if the initial file's is smaller than the player's height and the next file is greater than it, set the next file as initial quality
    463                         || ( $init_qual < $reference && $reference <= $quality['svq_order'] )
     463                        || ( (int) $init_qual < (int) $reference && (int) $reference <= (int) $quality['svq_order'] )
    464464                        // or if the next file's height is closer to and not smaller than the player's height, set it as initial quality
    465                         || ( abs( $reference - $init_qual ) > abs( $quality['svq_order'] - $reference ) && $quality['svq_order'] >= $reference )
     465                        || ( abs( (int) $reference - (int) $init_qual ) > abs( (int) $quality['svq_order'] - (int) $reference ) && (int) $quality['svq_order'] >= (int) $reference )
    466466                    ) {
    467                         $init_qual = $quality['svq_order'];
     467                        $init_qual = (int) $quality['svq_order'];
    468468                        $init_index = $key;
    469469                    }
Note: See TracChangeset for help on using the changeset viewer.