diff --git a/erpnext/public/js/hub/components/ItemCardsContainer.vue b/erpnext/public/js/hub/components/ItemCardsContainer.vue
index 5af82def829..748c2720f93 100644
--- a/erpnext/public/js/hub/components/ItemCardsContainer.vue
+++ b/erpnext/public/js/hub/components/ItemCardsContainer.vue
@@ -5,8 +5,7 @@
:message="empty_state_message"
:bordered="true"
:height="80"
- >
-
+ />
frappe.set_route(route));
+ },
+ unbind(el) {
+ el.classList.remove('cursor-pointer');
+ }
+});
+
+const handleImage = (el, src) => {
+ let img = new Image();
+ // add loading class
+ el.src = '';
+ el.classList.add('img-loading');
+
+ img.onload = () => {
+ // image loaded, remove loading class
+ el.classList.remove('img-loading');
+ // set src
+ el.src = src;
+ }
+ img.onerror = () => {
+ el.classList.remove('img-loading');
+ el.classList.add('no-image');
+ el.src = null;
+ }
+ img.src = src;
+}
+
+Vue.directive('img-src', {
+ bind(el, binding) {
+ handleImage(el, binding.value);
+ },
+ update(el, binding) {
+ if (binding.value === binding.oldValue) return;
+ handleImage(el, binding.value);
+ }
+});