Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addFiles (files) {
const currentImages = this.props.attributes.images || [];
const { noticeOperations, setAttributes } = this.props;
mediaUpload({
allowedTypes: ALLOWED_MEDIA_TYPES,
filesList: files,
onFileChange: images => {
const imagesNormalized = images.map(image => pickRelevantMediaFiles(image));
setAttributes({
images: currentImages.concat(imagesNormalized),
});
},
onError: noticeOperations.createErrorNotice,
});
}
addFiles( files ) {
const currentImages = this.props.attributes.images || [];
const { noticeOperations, setAttributes } = this.props;
mediaUpload( {
allowedTypes: helper.ALLOWED_MEDIA_TYPES,
filesList: files,
onFileChange: ( images ) => {
setAttributes( {
images: currentImages.concat( images ),
} );
},
onError: noticeOperations.createErrorNotice,
} );
}
addFiles( files ) {
const currentImages = this.props.attributes.images || [];
const { noticeOperations, setAttributes } = this.props;
mediaUpload( {
allowedType: 'image',
filesList: files,
onFileChange: ( images ) => {
setAttributes( {
images: currentImages.concat( images ),
} );
},
onError: noticeOperations.createErrorNotice,
} );
}
replaceImage( files ) {
mediaUpload( {
allowedTypes: [ 'image' ],
filesList: files,
onFileChange: ( [ media ] ) =>
this.props.setAttributes( { imageUrl: media.url, imageAlt: media.alt } ),
} );
}
addFile( files ) {
mediaUpload( {
allowedTypes: ALLOWED_BG_MEDIA_TYPES,
filesList: files,
onFileChange: ( [ media ] ) => this.onSelectFile( media ),
} );
}
onDropMedia( files ) {
mediaUpload( {
allowedTypes: ALLOWED_MEDIA_TYPES,
filesList: files,
onFileChange: ( [ media ] ) => this.onSelectMedia( media ),
} );
}
addImage( files ) {
mediaUpload( {
allowedTypes: [ 'image' ],
filesList: files,
onFileChange: ( [ media ] ) => this.onSelectImage( media ),
} );
}