Disable hard crop when using custom image sizing

lukasildza's Avatar


06 Nov, 2017 03:40 PM

Hi Dmitry,
i have a question, if there is already some possiblity to disable hard crop when setting custom image size.
I know you were already dealing with this here > http://help.dimsemenov.com/discussions/royalslider-wordpress/1670-no-subject

Problem is, solution which worked for this guy doesnt suit me. Im using one slider on homepage - http://www.lukasildza.sk/wp/ which was using "large" wordpress images. i need it to use originals (uploaded in 1920px) - so i used the code you provided into the functions.php

But i also use "default gallery" slider - for example here - http://www.lukasildza.sk/wp/projekt/royal-test-pawson/
I would like this slider to use smaller pics for main image, but still use full originals (also uploaded in 1920px) in fullscreen.
So, as long as i have overriden it in functions.php, this slider uses full images in the post too (out of fullscreen).
Only solution i can think of, is being able to set custom image size (which would maximum dimensions) but with cropping disabled.

Thanks in advance. Also have to say, its really great plugin.

  1. Support Staff 1 Posted by Dmitry Semenov on 06 Nov, 2017 09:03 PM

    Dmitry Semenov's Avatar


    You'll need to use PHP filter to create a custom variable that would return image size that you want, as described at http://help.dimsemenov.com/kb/wordpress-royalslider-advanced/wp-add...

    For example, if you're using slider that overrides [gallery] shortcode:

    // Add to your theme functions.php
    function add_royalslider_image_size($m, $attachment, $options) {
        $m->addHelper('custom_slider_image_url', function() use ($attachment) {
              // using https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/
              $image_info = wp_get_attachment_image_src( $attachment->ID, 'medium' );
               return $image_info[0];
        } );
    add_filter('new_rs_slides_renderer_helper','add_royalslider_image_size', 10, 4);

    The code above will create variable {{custom_slider_image_url}} that will return "medium" size of the image.

    Now just go to the slider that should use "medium" images, click on "Edit Slide Markup" in general options and replace {{image_tag}} with:

     <a class="rsImg" href="{{custom_slider_image_url}}" data-rsBigImg="{{large_image_url}}">{{title}}</a>

    (as described in docs of HTML version).


  2. 2 Posted by lukasildza on 09 Nov, 2017 01:26 PM

    lukasildza's Avatar

    Thanks Dmitry!
    Solution works as i was trying to achieve :)

  3. lukasildza closed this discussion on 09 Nov, 2017 01:26 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac