开发者 |
presswell
benplum |
---|---|
更新时间 | 2024年8月2日 22:14 |
PHP版本: | 4.0 及以上 |
WordPress版本: | 6.4.2 |
版权: | GNU General Public License v2.0 or later |
版权网址: | 版权信息 |
name
, key
, height
, width
, and optionally thumbnails
values; Thumbnail keys are prefixed with parent's key like '[size]-[thumbnail]'pwad_add_image_size( array( 'name' => 'Square', 'key' => 'square', 'width' => '1200', 'height' => '1200', 'thumbnails' => array( array( 'name' => 'Medium', 'key' => 'medium', 'width' => '800', 'height' => '800', ), array( 'name' => 'Small', 'key' => 'small', 'width' => '400', 'height' => '400', ), ), ) );
pwad_get_image( $attachment_ID, $size_key, $thumbnail_key )
$square_large = pwad_get_image( $img_ID, 'square' ); $square_medium = pwad_get_image( $img_ID, 'square', 'medium' ); $square_small = pwad_get_image( $img_ID, 'square-small' ); // Overloaded
pwad_get_image_src( $attachment_ID, $size_key, $thumbnail_key )
file
, url
, path
, height
, width
, and mime-type
values.
Example:
$square_large = pwad_get_image_src( $img_ID, 'square' ); $square_medium = pwad_get_image_src( $img_ID, 'square', 'medium' ); $square_small = pwad_get_image_src( $img_ID, 'square-small' ); // Overloaded
When viewing an image in the media library click the 'Set Focal Point' button. Use the size dropdown to change the crop preview. Click and drag the blue focal point marker to identify the subject of the image. When finished, click the 'Save Focal Point' button to update the focal point settings and clear the image thumbnail cache for regeneration.
Focal point hot-spots are an easy way to control the WordPress image crops because they do not requiring setting custom crop dimensions for every thumbnail size.
Themes may define many custom image thumbnail sizes, but not all image thumbnails will be displayed on the site. Dynamic image generation ensures only the image thumbnails that are actually used are created.
When migrating a large site it is beneficial to delete any generated image sizes to speed up the data transfer. Images will be re-generated dynamically when requested from the new location.