-1
I’m creating a new block of Gutenberg
which serves as an image gallery.
The idea is that the user can upload several images through the back-office.
For the attributes I have the following:
attributes: {
imgURL: {
type: 'string',
source: 'attribute',
attribute: 'src',
selector: 'img'
},
},
Inside the Edit:
edit: function( props ) {
const onFileSelect = (img) => {
props.setAttributes({
imgURL: img.url,
imgID: img.id,
imgAlt: img.alt
});
}
(...)
<MediaUpload
onSelect={onFileSelect}
value={1}
render= {({open}) =>
<Button
onClick={open}
>
Load image
</Button>
}
/>
For an image works well but I wanted the code to be dynamic. What will be the best approach ?
if the answer is right, don’t forget to mark as right @joão-dessain-saraiva
– pcarvalho