Skip to content

Commit 6b96581

Browse files
committed
ACP2E-2266: set itemprop for main product image with or w/o fotorama loading for all types of products.
1 parent f1aafd0 commit 6b96581

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

app/code/Magento/Catalog/view/frontend/requirejs-config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ var config = {
1818
mixins: {
1919
'Magento_Theme/js/view/breadcrumbs': {
2020
'Magento_Catalog/js/product/breadcrumbs': true
21+
},
22+
'mage/gallery/gallery': {
23+
'Magento_Catalog/js/gallery-mixin': true
2124
}
2225
}
2326
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/************************************************************************
2+
*
3+
* ADOBE CONFIDENTIAL
4+
* ___________________
5+
*
6+
* Copyright 2023 Adobe
7+
* All Rights Reserved.
8+
*
9+
* NOTICE: All information contained herein is, and remains
10+
* the property of Adobe and its suppliers, if any. The intellectual
11+
* and technical concepts contained herein are proprietary to Adobe
12+
* and its suppliers and are protected by all applicable intellectual
13+
* property laws, including trade secret and copyright laws.
14+
* Dissemination of this information or reproduction of this material
15+
* is strictly forbidden unless prior written permission is obtained
16+
* from Adobe.
17+
* ************************************************************************
18+
*/
19+
20+
define([
21+
'jquery',
22+
'mage/utils/wrapper'
23+
], function ($, wrapper) {
24+
'use strict';
25+
26+
return function (initialize) {
27+
// eslint-disable-next-line no-shadow
28+
return wrapper.wrap(initialize, function (initialize, config, element) {
29+
initialize(config, element);
30+
$(element).one('f:load', function (event) {
31+
if ($(event.target).hasClass('fotorama__active')) {
32+
$(event.target).find('img').attr('itemprop', 'image');
33+
}
34+
});
35+
});
36+
};
37+
});

dev/tests/js/jasmine/tests/lib/mage/gallery/gallery.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ define([
5757
position: '1',
5858
type: 'image',
5959
videoUrl: null,
60-
thumb: '',
61-
full: '',
62-
img: ''
60+
thumb: 'http://test.domain/thumb-image.jpeg',
61+
full: 'http://test.domain/full-image.jpeg',
62+
img: 'http://test.domain/image.jpeg'
6363
}
6464
],
6565
magnifierOpts: {
@@ -78,7 +78,7 @@ define([
7878
};
7979
element = $('<div class="gallery-placeholder' +
8080
' _block-content-loading" data-gallery-role="gallery-placeholder">' +
81-
'<img alt="main product photo" class="gallery-placeholder__image" src="">' +
81+
'<img alt="main product photo" class="gallery-placeholder__image" itemprop="image" src="">' +
8282
'</div>');
8383
});
8484

@@ -101,6 +101,7 @@ define([
101101
expect(gallery.settings.api).toBeDefined();
102102
expect(gallery.settings.activeBreakpoint).toEqual({});
103103
expect(gallery.config.options.height).toEqual(element.height());
104+
expect(gallery.settings.$elementF.find('.fotorama__stage__frame.fotorama__active img')).toBeDefined();
104105

105106
$.fn.data = originSpy;
106107
});

0 commit comments

Comments
 (0)