<$mt: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>
This page was last updated on 2011-07-22, 04:04.

3 Notes

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.

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/

primat: You can get a 240x240 or 75x75 thumbnail by deleting the file from assets_c and republishing whatever template has the thumbnail code for generating the square thumbs. This will regenerate the thumbnail as square if you use square="1".

The 240 thumbnail is used for the preview screen in Asset Manager, and is usually generated the first time you preview an asset. If you generate a square thumbnail using the method i described, this asset preview page will NOT regenerate a non-square thumbnail upon subsequent viewings. Instead, you will see your square version, stretched to fit the preview box. It's not an ideal solution, but if you need 240x240 thumbnails, that's how to get them. To get around similar issues in the past, i have just nuked the contents of assets_c and republished my site, to avoid picking out just the ones i want. Not sure if that approach would be recommended by all, but it has worked for me.

I did not test with 75 pixel thumbs but i'd guess it works similarly.

Hope that helps.

Leave a note

Have a question? Please use the MT Forums. Notes submitted on documentation should pertain to tips & hints regarding documentation. Your note may be removed once its contents have been integrated into the body of the page.