Change Log:
← Older revision
Revision as of 03:05, 17 April 2014
(5 intermediate revisions not shown)
Line 6:
Line 6:
== Description ==
== Description ==
−
Registers a new image size. This means that WordPress will create a copy of the Featured Image (formerly known as post thumbnail) with the specified dimensions when you upload a new image.
+
Registers a new image size. This means WordPress will create a copy of the Featured Image (formerly known as post thumbnail) with the specified dimensions when a new image is uploaded.
−
'''Note:''' To enable featured images, or post thumbnails, the current theme must include <code>[[Function Reference/add theme support|add_theme_support]]( 'post-thumbnails' );</code> in its <tt>[[Theme_Development#Functions_File|functions.php]]</tt> file. See also [[Post Thumbnails]].
+
'''Note:''' To enable featured images the current theme must include <code>[[Function Reference/add theme support|add_theme_support]]( 'post-thumbnails' );</code> in its <tt>[[Theme_Development#Functions_File|functions.php]]</tt> file. See also [[Post Thumbnails]].
== Usage ==
== Usage ==
Line 23:
Line 23:
:* false - Soft proportional crop mode.
:* false - Soft proportional crop mode.
:* true - Hard crop mode.
:* true - Hard crop mode.
−
:* array - Can specify positioning of the crop area.|optional|false}}
+
:* array - Specify positioning of the crop area (x_crop_position, y_crop_position).|optional|false}}
== Reserved Image Size Names ==
== Reserved Image Size Names ==
Line 29:
Line 29:
<code>thumb</code>, <code>thumbnail</code>, <code>medium</code>, <code>large</code>, <code>post-thumbnail</code>
<code>thumb</code>, <code>thumbnail</code>, <code>medium</code>, <code>large</code>, <code>post-thumbnail</code>
−
''The names "<code>thumb</code>" & "<code>thumbnail</code>" are just alias, so exactly the same.''
+
The names "<code>thumb</code>" & "<code>thumbnail</code>" are just aliases- they are exactly the same.
For a detailed explanation and "why", read further inside the [[Function_Reference/image_downsize#Description|image_downsize()]] article.
For a detailed explanation and "why", read further inside the [[Function_Reference/image_downsize#Description|image_downsize()]] article.
Line 54:
Line 54:
=== Crop Mode ===
=== Crop Mode ===
−
Set the image size by resizing the image proportionally (that is, without distorting it):
+
Set the image size by resizing the image proportionally (without distorting it):
−
<pre>add_image_size( 'homepage-thumb', 220, 180 ); // 220 pixels wide by 180 pixels tall, soft proportional crop mode</pre>
+
<pre>add_image_size( 'custom-size', 220, 180 ); // 220 pixels wide by 180 pixels tall, soft proportional crop mode</pre>
−
Set the image size by cropping the image (either from the sides, or from the top and bottom):
+
Set the image size by cropping the image (not showing part of it):
−
<pre>add_image_size( 'homepage-thumb', 220, 180, true ); // 220 pixels wide by 180 pixels tall, hard crop mode</pre>
+
<pre>add_image_size( 'custom-size', 220, 180, true ); // 220 pixels wide by 180 pixels tall, hard crop mode</pre>
+
+
Set the image size by cropping the image and defining a crop position:
+
<pre>add_image_size( 'custom-size', 220, 220, array( top, left ) ); // Hard crop top left</pre>
+
+
When setting a crop position, the first value in the array is the x axis crop position, the second is the y axis crop position.
+
+
* x_crop_position accepts 'left' 'center', or 'right'.
+
* y_crop_position accepts 'top', 'center', or 'bottom'.
== Using the New Image Sizes ==
== Using the New Image Sizes ==
Line 105:
Line 105:
== Change Log ==
== Change Log ==
+
* [[Version 3.9|3.9]] $crop parameter accepts array for crop positioning.
* Since [[Version 2.9|2.9]]
* Since [[Version 2.9|2.9]]