• Resolved hvnslab

    (@hvnslab)


    i’m building a portfolio site and need to showcase various videos with different aspect ratios. i’m using youtube to host but am having an issue with presto player not properly recognizing any aspect ratio that isn’t a standard 9:16. i have some 1:1, and 4:5 videos and they get cropped in weird ways. i tried using the prestoplayersettings code from previous posts and modified it to use if statements, then filtered for classes but it seems like prestoplayer can only use one aspect ratio per page load? is there a way to control each aspect ratio individually?

Viewing 1 replies (of 1 total)
  • Plugin Support prajna

    (@prajnajogi)

    Hello @hvnslab

    Can you please try the below filter, it will be invoked for each individual player setting, you can check the ID of the player settings.id in the callback and accordingly set the aspect ratio so it will be different for each video.

    add_action('wp_footer', function () { ?>
    
        <script>
    
            jQuery(function() {
    
                if (!wp || !wp.hooks) return;
    
                wp.hooks.addFilter('presto.playerSettings', 'pp-set-custom-aspect-ratio', function(settings) {
    
                    switch(settings.id) {
    
                        case 4:
    
                            settings.ratio = '16:9';
    
                            break;
    
                        case 3:
    
                            settings.ratio = '9:16';
    
                            break;
    
                        // Add more cases as needed
    
                        default:
    
                            // Default case if no match found
    
    settings.ratio = '16:9';
    
                            break;
    
                    }
    
                    return settings;
    
                });
    
            });
    
        </script>
    
    <?php });


    Depending on the settings.id, the aspect ratio (settings.ratio) of the video player is set accordingly. For example, if settings.id is 3, the aspect ratio will be set to 9:16 in this case.

    I hope the above information will work for you. Let me know how it goes.


Viewing 1 replies (of 1 total)
  • The topic ‘individual aspect ratio control’ is closed to new replies.