How do I pre-set the height/width of IMG tags for thumbnails in templates?


<< Can PortWeb do date-based ...
Back to Portfolio FAQ index
Using the Extensis 'makeN ... >>

Portfolio doesn't Provide this information, nor does the %Thumbnail% macro write height and width tags. You could export all the thumbnails to a 99x99 static web page and then re-catalogue the exported thumbnail images to get height/width.

However, there is an easier way. You do know the original height and width and you know the longest side of the thumbnail (112 or 256 pixels). So using some JavaScript if you pass the original height & width (i.e. %height%, %width%) to a JS function that can check the orientation and work out the thumbnail height, width.

Consider a picture 400 pixels wide and 200 deep. The longest side of the thumbnail is the longer of the original's height & width - thus the thumbnail is 112 pixels wide. Now the shorter side must be 112 * (200/400) = 112 * 0.5 = 56. So the JS writes the width attribute as "112" and the height as "56".

Don't forget to allow for exactly square images where both the height and width will be the same - i.e. in our example both would be "112".



Question: How do I pre-set the height/width of IMG tags for thumbnails in templates? [FAQ00228.htm]
Last Update:- 31 May 2006


<< Can PortWeb do date-based ...
Back to Portfolio FAQ index
Using the Extensis 'makeN ... >>

Quick Search of PortfolioFAQ (word, words or phase): or try the Advanced Search

User-to-User Forums  |  Report error/typo/broken link  |  Request new topic  |  Ask a question

Site and articles © Mark Anderson 2001-2007 - Visit my home page


This FAQ is created and maintained using
Friday logo
Friday - The Automatic FAQ Maker