Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/design/themes/responsive/templates/common/image.tpl b/design/themes/responsive/templates/common/image.tpl
index b35ee62327..1316d5f2c1 100644
--- a/design/themes/responsive/templates/common/image.tpl
+++ b/design/themes/responsive/templates/common/image.tpl
@@ -4,10 +4,6 @@
{capture name="image"}
{/if}
-{if !$obj_id}
- {math equation="rand()" assign="obj_id"}
-{/if}
-
{$image_data = $images|fn_image_to_display:$image_width:$image_height}
{$generate_image = $image_data.generate_image && !$external}
{$show_no_image = $show_no_image|default:true}
@@ -20,6 +16,16 @@
{$image_link_additional_attrs["title"] = $images.detailed.alt}
{/if}
+{if !$obj_id}
+ {if $image_data.image_path}
+ {$obj_id = $image_data.image_path|crc32}
+ {elseif $image_id}
+ {$obj_id = $image_id|crc32}
+ {else}
+ {$obj_id = uniqid()}
+ {/if}
+{/if}
+
{hook name="common:image"}
{if $show_detailed_link}
<a id="det_img_link_{$obj_id}" {if $image_data.detailed_image_path && $image_id}data-ca-image-id="{$image_id}"{/if} class="{$link_class} {if $image_data.detailed_image_path}cm-previewer ty-previewer{/if}" data-ca-image-width="{$images.detailed.image_x}" data-ca-image-height="{$images.detailed.image_y}" {if $image_data.detailed_image_path}href="{$image_data.detailed_image_path}" {$image_link_additional_attrs|render_tag_attrs nofilter}{/if}>
diff --git a/design/themes/responsive/templates/views/products/components/product_images.tpl b/design/themes/responsive/templates/views/products/components/product_images.tpl
index 9ca3ac1aa6..2909f609a6 100644
--- a/design/themes/responsive/templates/views/products/components/product_images.tpl
+++ b/design/themes/responsive/templates/views/products/components/product_images.tpl
@@ -13,7 +13,7 @@
{/if}
{if !$preview_id}
- {assign var="preview_id" value=$product.product_id|uniqid}
+ {$preview_id = $product.product_id}
{/if}
<div class="ty-product-img cm-preview-wrapper" id="product_images_{$preview_id}">
@@ -120,4 +120,4 @@
{include file="common/previewer.tpl"}
{script src="js/tygh/product_image_gallery.js"}
-{hook name="products:product_images"}{/hook}
\ No newline at end of file
+{hook name="products:product_images"}{/hook}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment