Skip to content

Instantly share code, notes, and snippets.

@adriannees
Last active September 6, 2016 23:26
Show Gist options
  • Select an option

  • Save adriannees/cecfb4c393dd77ecb59b62b7e731f019 to your computer and use it in GitHub Desktop.

Select an option

Save adriannees/cecfb4c393dd77ecb59b62b7e731f019 to your computer and use it in GitHub Desktop.
Custom Image Size (WordPress)
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add new custom image sizes
add_image_size( 'image-name', 150, 100, TRUE );
/* DO NOT include the following it is for instructional purpose only
*
* Replace 'image-name' with the descriptive name you want to identify the new image size with.
* DO NOT use thumb, thumbnail, medium, large, or post-thumbnail
* The next two numbers are the width and height of the image in pixels respectively.
* The final TRUE/FALSE is in response to assumed question "Should this image be cropped to these dimensions". If true it will be cropped.
* If false the image will be scaled, not cropped (not recommended). If true can also specify where to crop in the form of an array.
* x_crop_position accepts 'left', 'center', or 'right' and y_crop_position accepts 'top', 'center', or 'bottom'
* ex. add_image_size( 'custom-size', 220, 200, array( 'left', 'top' ) ); // hard crops the top left 220x200 of image
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment