• Resolved rtpHarry

    (@rtpharry)


    It seems like there is a bug in the architecture of the plugin.

    The filter ‘cycloneslider_image_sizes’ is in theory made available to set up custom sizes:

    $plugin['image_sizes'] = apply_filters('cycloneslider_image_sizes', $plugin['image_sizes']);

    This can’t ever get called though because the plugin activates itself on the ‘plugins_loaded’ event which is called before anything in functions.php so by the time any custom ‘cycloneslider_image_sizes’ filters are defined the filter has already been called.

    If you look in codex action reference you will see that it says normally plugins are set up in the ‘init’ event which would fire after the functions.php has a chance to set itself up.

    SOLUTION

    In cyclone-slider.php line 30 edit ‘plugins_loaded’ to ‘init’.

    Then users of the plugin can set up custom image sizes in functions.php like this:

    // wire up extra sizes in plugin
    function custom_template_size($template_sizes)
    {
        $template_sizes['440_266_crop'] = array(
            'width' => 440,
            'height' => 266,
            'resize_option' => 'crop',
        );
    
        return $template_sizes;
    }
    add_filter('cycloneslider_image_sizes', 'custom_template_size');

    https://wordpress.org/plugins/cyclone-slider-2/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter rtpHarry

    (@rtpharry)

    Actually this doesn’t completely solve the problem.

    It solves the resizing problem but then the admin pages all disappear, I guess that some of the init code does need to be run in the ‘plugins_loaded’ filter.

    Plugin Author kosinix

    (@kosinix)

    Hello rtpHarry,

    Thank you for taking the time reporting writing this issue. You are correct, this looks like an architectural bug. I’ll work on a solution in the next release. For now you can use a sub plugin:

    Create a file in wp-content\plugins\ and name it cyclone-slider-image-sizes-override.php

    Inside it put this code:

    <?php
    /*
    Plugin Name: Cyclone Slider: Image Sizes Override
    Version: 1.0
    Description: A way to override the image sizes in Cyclone Slider
    License: GPLv3
    License URI: https://www.gnu.org/licenses/gpl-3.0.html
    */
    
    add_action('plugins_loaded', function () {
        add_filter('cycloneslider_image_sizes', function($image_sizes){
            $image_sizes['40_40_crop'] = array(
                'width' => 60,
                'height' => 60,
                'resize_option' => 'crop'
            );
            return $image_sizes;
        });
    }, 9 );

    Change the image_sizes array to suit your needs then activate the plugin. Bonus point, you wont lose your changes in case your theme got updated (functions.php is overwritten)

    Plugin Author kosinix

    (@kosinix)

    cycloneslider_image_sizes now fires at a later time. Marking this as fixed

    Thread Starter rtpHarry

    (@rtpharry)

    Thanks for the prompt update.

    I had it in my todo list to take another look at it but when I went to investigate it a second time I realised it had already installed the new version, overwritten the resize modifications I’d made to the core files and had automatically started using the cycloneslider_image_sizes filter I’d tried to set up the first time.

    It’s not often you go to do a job and find that it’s already completed itself! haha

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘BUG in design – setting custom sizes’ is closed to new replies.