|
@@ -121,6 +121,18 @@ export default class ImageUploadEngine extends Plugin {
|
|
|
doc.enqueueChanges( () => {
|
|
doc.enqueueChanges( () => {
|
|
|
batch.setAttribute( imageElement, 'uploadStatus', 'complete' );
|
|
batch.setAttribute( imageElement, 'uploadStatus', 'complete' );
|
|
|
batch.setAttribute( imageElement, 'src', data.original );
|
|
batch.setAttribute( imageElement, 'src', data.original );
|
|
|
|
|
+
|
|
|
|
|
+ // Srcset attribute for responsive images support.
|
|
|
|
|
+ const srcsetAttribute = Object.keys( data )
|
|
|
|
|
+ // Filter out keys that are not integers.
|
|
|
|
|
+ .filter( key => !isNaN( parseInt( key, 10 ) ) )
|
|
|
|
|
+
|
|
|
|
|
+ // Create `srcset` attribute value from all elements in the array.
|
|
|
|
|
+ .reduce( ( acc, key ) => `${ data[ key ] } ${ key }w,`, '' );
|
|
|
|
|
+
|
|
|
|
|
+ if ( srcsetAttribute != '' ) {
|
|
|
|
|
+ batch.setAttribute( imageElement, 'srcset', srcsetAttribute );
|
|
|
|
|
+ }
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
clean();
|
|
clean();
|