Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Change Crop Position for Slider Images

Would you like to change the crop position on slider images? We can walk you through how to do this! Follow the tutorial below to change the crop position on your Soliloquy slider images.

Note: This tutorial is a bit more technical than our other docs, but we’ll walk you through the process step by step. In order to change the default crop position, we’ll need to create and upload a basic WordPress plugin.


Creating the Plugin

To set the slider title before your sliders, just add the following code to a new file at wp-content/plugins/soliloquy-change-crop-position.php.

[php]<?php
/**
* Plugin Name: Soliloquy – Change Crop Position
* Plugin URI: https://soliloquywp.com
* Version: 1.0
* Author: Soliloquy Team
* Author URI: https://soliloquywp.com
* Description: Set Soliloquy images to be cropped from the to top, bottom, left or right
*/

/**
* Change the position where images are cropped from (default = center)
*
* @param array $args Resize Arguments
* @return array Resize Arguments
*/
function sol_soliloquy_crop_images_position( $args ) {

/**
* Accepted Positions:
* tl: top left
* tr: top right
* c: center
* bl: bottom left
* br: bottom right
*/
$args[‘position’] = ‘tl’;
return $args;

}
add_filter( ‘soliloquy_crop_image_args’, ‘sol_soliloquy_crop_images_position’ );[/php]

If you’re unsure how to create a plugin file, follow these steps below:

  1. Open a text file and make sure that it is a plain text document. You can use a plain text editor like Notepad or a code editor of your choice.
  2. Next, copy and paste the code shown above into the file and save the file as soliloquy-change-crop-position.php
  3. Once you’ve saved the file you can easily upload this directly to your /plugins directory on your server using FTP or you can right-click on the text document and zip (or compress).
  4. Finally, log in to your WordPress dashboard and go to Plugins » Add New » Upload Plugin and upload the .zip file you just created in the previous step.

Edit the crop position in the plugin

Next, make sure the plugin has the correct position set in the $args['position'] = 't';. In our example the tl is set to crop all images from the top left.

Activate the Plugin

Your next step is to activate the plugin you just uploaded. Simply navigate to the Plugins from within your WordPress dashboard and activate the Soliloquy – Change Crop Position plugin.

To change the default crop position, activate the custom plugin

And that’s it! You’ve just changed the default crop position!

If you’d like to customize Soliloquy further, take a look at our Extending documentation on other customizations you can make to the plugin.


FAQs

Can I set a different crop position for each slider?

A: Not at this time. This custom plugin will change all crop positions for all newly created uploaded slider images.


What about my previously created sliders?

A: In order to update your previously created sliders, you’ll need to edit the sliders, change the Image Size from the Configuration tab and Update the gallery to force the regenerations of those slider cropped images.