Dynamic Resize Images Based on URL
//Pass Image size, image type and product code in as parameters
<img src="/request_image.jpg?Product_Code=test&image_type=main&image_height=200&image_width=500" border="0" />
//Add .htacces rewrite rule
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/request_image.jpg$ [NC]
RewriteRule ^(.*)$ http://domain.com/mm5/merchant.mvc?Screen=REQUEST_IMAGE [QSA,L]
//create a new page in Miva called REQUEST_IMAGE with the following code:
<mvt:assign name="l.constraints[1]:height" value="encodeentities(g.image_height)" />
<mvt:assign name="l.constraints[1]:width" value="encodeentities(g.image_width)" />
<mvt:assign name="l.imagetype_codes[1]" value="encodeentities(g.image_type)" />
<mvt:do name="l.success" file="g.Module_Library_DB" value="Product_Load_Code( encodeentities(g.Product_Code), l.settings:product )" />
<mvt:assign name="l.constraints_count" value="miva_array_elements( l.constraints )" />
<mvt:assign name="l.imagetypecode_count" value="miva_array_elements( l.imagetype_codes )" />
<mvt:do file="g.Module_Library_DB" name="l.imagedata_count" value="ProductImageDataList_Load_Product_TypeCodes_Constrained(l.settings:product:id, l.imagetype_codes, l.imagetypecode_count , l.constraints,l.constraints_count,l.settings:productimagedatalist)" />
<mvt:comment>
Check and see if the image size requested exists on the server, If not dynamically create it
</mvt:comment>
<mvt:if expr="ISNULL l.settings:productimagedatalist[1]:generatedimages[1]:image">
<mvt:do file="g.Module_Library_DB" name="l.ok" value="GeneratedImage_FindOrInsert_Image_Dimensions( l.settings:productimagedatalist[1]:image, l.constraints[1]:width, l.constraints[1]:height, l.settings:generatedimage )" />
<mvt:assign name="l.ok" value="file_read( '/' $ g.Domain:mod_root $ l.settings:generatedimage:image, 'script', g.image_data)" />
<mvt:else>
<mvt:assign name="l.ok" value="file_read( '/' $ g.Domain:mod_root $ l.settings:productimagedatalist[1]:generatedimages[1]:image, 'script', g.image_data)" />
</mvt:if>
<mvt:eval expr="g.image_data" />
Also there is a JavaScript method to pull any image you want with any dimensions:
Make a call to json.mvc with the following parameters:
Session_Type=runtime Function=Runtime_ProductImageList_Load_Product_Var iant Product_Code= Variant_ID= Image_Sizes=pipe separated lists of dimensions, either the string “original” or WIDTHxHEIGHT
The output will be a JSON array containing URLs to the generated product images.
You would then read in the JSON and update the page accordingly.