2 images in same block
-
Hi all,
Im having a hard time making 2 images work in the same block.
I’ve made a block that I’ve named “Main case” – and I need to upload 2 images.
The problem is, that it works INITIALLY….But when I refresh the page, the FIRST image URL is set as src for both images.
Any idea why this is?My attributes:
attributes: { primaryTitle: { type: 'array' }, primaryLargeMediaID: { type: 'number' }, primaryLargeMediaURL: { type: 'string', source: attr( 'img', 'src' ) }, primarySmallMediaID: { type: 'number' }, primarySmallMediaURL: { type: 'string', source: attr( 'img', 'src' ) }, primaryCaseUrl: { type: 'string' }, primaryTeaser: { type: 'array' } },
My setAttributes:
function onSelectLargeImage ( mediaLarge ) { props.setAttributes( { primaryLargeMediaURL: mediaLarge.url, primaryLargeMediaID: mediaLarge.id } ); } function onSelectSmallImage ( mediaSmall ) { props.setAttributes( { primarySmallMediaURL: mediaSmall.url, primarySmallMediaID: mediaSmall.id } ); }
My elements:
el( 'div', { className: 'large-img' }, el( blocks.MediaUploadButton, { buttonProps: { className: attributes.primaryLargeMediaID ? 'large-image-button' : 'components-button button button-large' }, onSelect: onSelectLargeImage, type: 'image', value: attributes.primaryLargeMediaID }, attributes.primaryLargeMediaID ? el( 'img', { src: attributes.primaryLargeMediaURL } ) : 'Upload large image' ) ), el( 'div', { className: 'desc-img' }, el( blocks.MediaUploadButton, { buttonProps: { className: attributes.primarySmallMediaID ? 'small-image-button' : 'components-button button button-large' }, onSelect: onSelectSmallImage, type: 'image', value: attributes.primarySmallMediaID }, attributes.primarySmallMediaID ? el( 'img', { src: attributes.primarySmallMediaURL } ) : 'Upload small image' ) ),
Any ideas?
I’m a bit lost here….Best regards
AK
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘2 images in same block’ is closed to new replies.