Skip to content

Output Specific Sized Product Image#


Description#

Output Specific Sized Product Image

Snippet#

<mvt:assign name="l.constraints[1]:height" value="600" />
<mvt:assign name="l.constraints[1]:width" value="600" />
<mvt:assign name="l.imagetype_codes[1]" value="'main'" />

<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 exists, if not, Generate the file and return its path.
</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:generatedimage:image;
<mvt:else>
  &mvt:productimagedatalist[1]:generatedimages[1]:image;
</mvt:if>

Functions Used#

  • miva_array_elements
  • ProductImageDataList_Load_Product_TypeCodes_Constrained
  • GeneratedImage_FindOrInsert_Image_Dimensions