Skip to main content

[WP] Using WordPress image sizes

There is a filter new_rs_image_sizes that allows you to modify image sizes that slider uses.

// Add code to your theme functions.php
function royalslider_change_image_size($sizes) {
// here is how sizes object looks by default
/* $sizes = array(
'full' => 'full',
'large' => 'large',
'thumbnail' => 'thumbnail'
); */

// here is how to modify large image
$sizes['large'] = 'your-custom-size-name';
return $sizes;
}
add_filter( 'new_rs_image_sizes', 'royalslider_change_image_size' );

To make RoyalSlider use these image sizes, make sure that there are no values in width and height inputs in "Image Options" section of slider options.

If you don't know how to create custom WordPress image sizes, check this article.

The easiest plugin that allows to add image size via WordPress admin is Simple Image Sizes. For example, if you created image size with name "my-custom-thumbnail" and you want to use it as a thumbnail for RoyalSlider, use such code (and don't forget to remove values from thumbnail width/height in Image Options of slider):

function royalslider_change_thumbnail_size($sizes) {
$sizes['thumbnail'] = 'my-custom-thumbnail';
return $sizes;
}
add_filter( 'new_rs_image_sizes', 'royalslider_change_thumbnail_size' );

How to use originally uploaded images

// Add code to your theme functions.php
function royalslider_use_original_images($sizes) {
$sizes['large'] = 'full';
return $sizes;
}
add_filter( 'new_rs_image_sizes', 'royalslider_use_original_images' );