feat: add automatic fallback to placeholder for broken product images
Issue: - Product images in database have fake URLs (wizamart.example.com) that don't exist - Browser shows broken image icons instead of placeholder Solution: - Add @error handler to all product images to fallback to placeholder.svg - When any image fails to load, automatically switch to placeholder - Applies to: product detail page, products list, related products Now all broken/invalid image URLs will automatically show the placeholder instead of broken image icons. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
<div class="main-image bg-white dark:bg-gray-800 rounded-lg overflow-hidden mb-4">
|
<div class="main-image bg-white dark:bg-gray-800 rounded-lg overflow-hidden mb-4">
|
||||||
<img
|
<img
|
||||||
:src="selectedImage || '/static/shop/img/placeholder.svg'"
|
:src="selectedImage || '/static/shop/img/placeholder.svg'"
|
||||||
|
@error="selectedImage = '/static/shop/img/placeholder.svg'"
|
||||||
:alt="product?.marketplace_product?.title"
|
:alt="product?.marketplace_product?.title"
|
||||||
class="w-full h-auto object-contain"
|
class="w-full h-auto object-contain"
|
||||||
style="max-height: 600px;"
|
style="max-height: 600px;"
|
||||||
@@ -187,6 +188,7 @@
|
|||||||
<a :href="`{{ base_url }}shop/products/${related.id}`">
|
<a :href="`{{ base_url }}shop/products/${related.id}`">
|
||||||
<img
|
<img
|
||||||
:src="related.marketplace_product?.image_link || '/static/shop/img/placeholder.svg'"
|
:src="related.marketplace_product?.image_link || '/static/shop/img/placeholder.svg'"
|
||||||
|
@error="$el.src = '/static/shop/img/placeholder.svg'"
|
||||||
:alt="related.marketplace_product?.title"
|
:alt="related.marketplace_product?.title"
|
||||||
class="w-full h-48 object-cover"
|
class="w-full h-48 object-cover"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm hover:shadow-md transition-shadow overflow-hidden">
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm hover:shadow-md transition-shadow overflow-hidden">
|
||||||
<a :href="`{{ base_url }}shop/products/${product.id}`">
|
<a :href="`{{ base_url }}shop/products/${product.id}`">
|
||||||
<img :src="product.marketplace_product?.image_link || '/static/shop/img/placeholder.svg'"
|
<img :src="product.marketplace_product?.image_link || '/static/shop/img/placeholder.svg'"
|
||||||
|
@error="$el.src = '/static/shop/img/placeholder.svg'"
|
||||||
:alt="product.marketplace_product?.title"
|
:alt="product.marketplace_product?.title"
|
||||||
class="w-full h-48 object-cover">
|
class="w-full h-48 object-cover">
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user