@@ -176,42 +176,6 @@ export function createOptimizedPicture(src, alt = '', eager = false, breakpoints
176
176
return picture ;
177
177
}
178
178
179
- /*
180
- * Decorates external images with a picture element
181
- * @param {Element } ele The element
182
- * @param {string } deliveryMarker The marker for external images
183
- * @private
184
- * @example
185
- * decorateExternalImages(main, '//External Image//');
186
- */
187
- function decorateExternalImages ( ele , deliveryMarker ) {
188
- const extImages = ele . querySelectorAll ( 'a' ) ;
189
- extImages . forEach ( ( extImage ) => {
190
- if ( isExternalImage ( extImage , deliveryMarker ) ) {
191
- const extImageSrc = extImage . getAttribute ( 'href' ) ;
192
- const extPicture = createOptimizedPicture ( extImageSrc ) ;
193
-
194
- /* copy query params from link to img */
195
- const extImageUrl = new URL ( extImageSrc ) ;
196
- const { searchParams } = extImageUrl ;
197
- extPicture . querySelectorAll ( 'source, img' ) . forEach ( ( child ) => {
198
- if ( child . tagName === 'SOURCE' ) {
199
- const srcset = child . getAttribute ( 'srcset' ) ;
200
- if ( srcset ) {
201
- child . setAttribute ( 'srcset' , appendQueryParams ( new URL ( srcset , extImageSrc ) , searchParams ) ) ;
202
- }
203
- } else if ( child . tagName === 'IMG' ) {
204
- const src = child . getAttribute ( 'src' ) ;
205
- if ( src ) {
206
- child . setAttribute ( 'src' , appendQueryParams ( new URL ( src , extImageSrc ) , searchParams ) ) ;
207
- }
208
- }
209
- } ) ;
210
- extImage . parentNode . replaceChild ( extPicture , extImage ) ;
211
- }
212
- } ) ;
213
- }
214
-
215
179
/**
216
180
* Decorates all images in a container element and replace media urls with delivery urls.
217
181
* @param {Element } main The container element
@@ -242,11 +206,13 @@ function decorateDeliveryImages(main) {
242
206
*/
243
207
// eslint-disable-next-line import/prefer-default-export
244
208
export function decorateMain ( main ) {
245
- // decorate external images with explicit external image marker
246
- decorateExternalImages ( main , '//External Image//' ) ;
209
+ if ( window . hlx . aemassets . decorateExternalImages ) {
210
+ // decorate external images with explicit external image marker
211
+ window . hlx . aemassets . decorateExternalImages ( main , '//External Image//' ) ;
247
212
248
- // decorate external images with implicit external image marker
249
- decorateExternalImages ( main ) ;
213
+ // decorate external images with implicit external image marker
214
+ window . hlx . aemassets . decorateExternalImages ( main ) ;
215
+ }
250
216
251
217
// decorate images with delivery url and correct alt text
252
218
decorateDeliveryImages ( main ) ;
0 commit comments