AssetThumbnailURL
Returns the URL for a thumbnail you wish to generate for the current asset in context.
Attributes:
- height
The height of the thumbnail to generate. If this is the only parameter specified then the thumbnail’s width will be scaled proportionally to the height. When the longer value than the original image is specified, it will be ignored.
- width
The width of the thumbnail to generate. If this is the only parameter specified then the thumbnail’s height will be scaled proportionally to the width. When both of height and width are specified, the longer side of the original image will be processed, and the lesser side will be scaled proportionally.
- scale
The percentage by which to reduce or increase the size of the current asset.
- square
If set to 1 (one) then the thumbnail generated will be square, where the length of each side of the square will be equal to the shortest side of the image.
Example:
The following will output thumbnails for all of the assets embedded in all of the entries on the system. Each thumbnail will be square and have a max height/width of 100 pixels.
<mt:Entries> <mt:EntryAssets> <$mt:AssetThumbnailURL width="100" square="1"$> </mt:EntryAssets> </mt:Entries>
primat on July 7, 2010, 8:49 a.m. Reply
Apparently, MT generates thumbnails automatically. These are placed in the asset_c folder and the thumb filenames contain 75-75 and 240-240 implying that they are square thumbnails. This is not the case, however. In MT’s unintuitive fashion, the thumbs are actually scaled to 75 and 240 pixels with respect to the dimension of the original image which is larger.
Second problem with this is that if you actually want to use MT to create a square thumbnail of an image with dimensions 75x75 or 240x240, it won’t work because the file is already created and therefore the thumbnail is not generated.
Although the thumbnail feature is handy, its implementation is very poorly thought out and consequently, counter-intuitive.
Also, it’s sad that MT will crop image to a square image (when square=”1” is used), but it will not crop images when both a height and width are used. This really limits this features usefulness.
Jue Wang on July 8, 2010, 1:36 p.m. Reply
Yeah, there are a lot of wrong / buggy things about the way this is implemented. Fortunately, a flexible cropping functionality isn’t hard to achieve with PHP—here’s one option: http://jueseph.com/2010/06/opticrop-content-aware-cropping-with-php-and-imagemagick/