![]() |
| > Home > Documentation > Latest documentation > Interchange tags > image |
|
imageWrapper for the generation of <img> HTML tags. Summary
ExamplesTag expansion example
Perl example
or similarly with positional parameters:
DescriptionThis is a general-purpose tag for inserting <img> HTML tags, based upon various settings, with the ability to do the following and more:
A convenient use is for displaying product images on an ecommerce website. For example, on the flypage:
Assuming that the SKU is "ABC123, and assuming the DefaultTables table specifies "ABC123.gif" in its "image" column for the "ABC123" row, this tag will return HTML code along the lines of the following:
If there is no ABC123.gif, or the DefaultTables table's "image" column for the "ABC123" row was empty, this tag would check for files called "ABC123.jpg and this tag check for files called "ABC123.jpg" and "ABC123.png" etc. You can also specify a particular image filename, but also use the sku parameter to look up the description in the database, as follows:
You can force the use of an image filename even if the file doesn't exist (if it's on a different server, for example). Absolute URIs beginning with "http://" or "https://" are always accepted without checking, of course, and the force parameter can be used to avoid all such checks on local files. One peculiar use is with the dir_only parameter to return the correct prefix for images (HTTP or HTTPS/SSL), primarily for adding to image names used in JavaScript code and elsewhere. ParameterssrcThis parameter is used to specify the location of the image. If the value starts with "http://" or "https://" then it will be used as-is, otherwise it will be assumed to be an image file, on the local filesystem. If this parameter starts with a "/" then it will be used verbatim in the resulting HTML <img> tag. The path used for existance and getsize checks etc. will be relative from the website's home directory, as specified using the Catalog global configuration directive. If this parameter does not start with a "/" then the value of either the ImageDir or the ImageDirSecure local configuration directive will be prepended, depending upon whether or not the current page was requested via a HTTPS/SSL link. Also see the ui parameter, which can be used to change the image directory used by this tag, and also the imagesubdir parameter. If the named local file cannot be found then the ".jpg", ".gif", ".png" and ".jpeg" suffixes will be appended to the file, in turn, in an attempt to find the image, If the image cannot be found on the local filesystem then the src value will be looked up in the DefaultTables table(s). If it still can't be found then the sku parameter's value will be looked up in the DefaultTables table(s). If no image file can be found then the default value will be used instead. altAlternate text for the browser to show if the image can't be displayed, for whatever reason. If no alt parameter is provided, and the src parameter's value does not start with "http://" or "https://", then the src will be looked up in the DefaultTables table(s). If a row is found then the columns named in the descriptionfields parameter will be searched for a value instead. Also see the sku parameter's description. check_dateThis parameter is designed to be used in combination with the makesize parameter. if set true then this tag will check the image file's modification time. If the resized image is found to be out of date then it will be rebuilt before being served. defaultImage filename, or URI, that will be used if no image file that matches the src value can be found. If no default parameter is specified then the [scratch mv_imagedefault] value will be used, if set. descriptionfieldsWhitespace-separated list of columns in the DefaultTables table(s) to be scanned for a default alternate text value. If this parameter is not provided then the DESCRIPTIONFIELDS Variable will be used. If that Variable is not set then the value of the DescriptionField local configuration directive will be used. The ultimate default value is "description". dir_onlyIf this parameter is set true then this tag will simply return the value of either the ImageDir or the ImageDirSecure local configuration directive, depending upon whether or not the current page was requested via a HTTPS/SSL link. Also see the ui parameter, which can be used to change the image directory used by this tag. exists_onlyIf this parameter is set true then this tag will return 1 if the named image file exists. extraExtra attributes to be passed verbatim to the resulting HTML <img> tag. forceSkip any checks on image file's existence. getsizeIf this parameter is set true, and the
Image::Size This parameter will override the values specified using the height and width parameters.
This parameter will be ignored if the src parameter refers to an external URI. Also see the size_scratch_prefix parameter. imagefieldsWhitespace-separated list of columns in the DefaultTables table(s) to be scanned for an image filename or URI. If this parameter is not provided then the IMAGEFIELDS Variable will be used. The default value is "image".
imagesubdirLook for the image file in the named subdirectory of the ImageDir (or ImageDirSecure) directory. makesize
If ImageMagick This parameter's value is expected to be specified as "WIDTHxHEIGHT" or "xHEIGHT", which can optionally be followed by up to two offset specifications, the first for the X offset, and the second for the Y offset, as follows:
In addition to the standard X Window System's geometry specification syntax, the following qualifier tokens are accepted at the end of the parameter.
This tag resizes images by copying the original into a size-named
subdirectory and then running
ImageMagick's
securePassing "0" to this parameter will force this tag to act as if the page request was made over a HTTP link. Either the ImageDir local configuration directive, or the UI_IMAGE_DIR variable will be used as the default image directory. Passing "1" to this parameter will force this tag to act as if the page request was made over a HTTPS/SSL link. Either the ImageDirSecure local configuration directive, or the UI_IMAGE_DIR_SECURE variable will be used as the default image directory. If this parameter is not specified at all then the [image] tag will work out for itself whether a HTTP or HTTPS/SSL link is in use. size_scratch_prefixIf getsize is true and this parameter has a value, then the determined image size will be saved into scratchpad variables. For example, if this parameter is set to "foobar" then two scratchpad variables will be created, named "foobar_width" and "foobar_height", each with a corresponding image size value. skuThis parameter allows you to specify a value that should be used to look up the alt text in the DefaultTables table(s), instead of using the src value for this purpose. If no src parameter is supplied, or the supplied src parameter doesn't point to an existing file, then the sku will also be used to try to find an image in the DefaultTables table(s). If the provided sku doesn't yield a row in the DefaultTables table(s), then the src parameter's value will be tried. src_onlyIf this parameter is set true then this tag will return the image path and filename, exactly as it would have been used in the <img> HTML tag's src attribute. titleText to use with the <img> HTML tag's "title" attribute. If this parameter is not specified then the value of the alt parameter, or that parameter's calculated default, will be used. uiIf this parameter is set true then this tag will use the UI_IMAGE_DIR and UI_IMAGE_DIR_SECURE variables instead of the ImageDir the ImageDirSecure local configuration directives to determine the image directory.
|
| Home | Legal nonsense | Privacy policy | Contact us |