diff --git a/src/image/extend.js b/src/image/extend.js index 3273ef9..232605d 100644 --- a/src/image/extend.js +++ b/src/image/extend.js @@ -17,6 +17,7 @@ const { Disabled, Button, ResponsiveWrapper, + ToggleControl, } = wp.components; const { useSelect } = wp.data; @@ -179,6 +180,10 @@ function getCopyright(image) { return image && image.media_fields ? get(image, 'media_fields.field_copyright.value.value') : ''; } +function getDisplayCopyright(image) { + return get(image, 'media_fields.field_copyright_enable.value.value') === 'on' ? true : false; +} + function getCrop(image, cropName) { if (!image) return; const key = Object.keys(image.media_details.crops).find((key) => { @@ -298,6 +303,7 @@ const withSrcAttribute = createHigherOrderComponent((BlockEdit) => { ? props.attributes.alt : get(image, 'media_fields.field_media_image.value.alt'), copyright: get(image, 'media_fields.field_copyright.value.value'), + displayCopyright: getDisplayCopyright(image), size: !props.attributes.size ? sizeControlOptions.find((o) => o.default).value : props.attributes.size, @@ -472,6 +478,12 @@ const withSrcAttribute = createHigherOrderComponent((BlockEdit) => { help={__('Could be changed in gallery')} value={getCopyright(image)} /> + + diff --git a/src/image_gallery/extend.js b/src/image_gallery/extend.js index f6ae39e..5bb8630 100644 --- a/src/image_gallery/extend.js +++ b/src/image_gallery/extend.js @@ -8,7 +8,7 @@ const { createHigherOrderComponent } = wp.compose; const { InspectorControls } = wp.blockEditor; const { Fragment } = wp.element; const { addFilter } = wp.hooks; -const { PanelBody, TextControl, Disabled } = wp.components; +const { PanelBody, TextControl, Disabled, ToggleControl } = wp.components; const { useSelect } = wp.data; const { __ } = wp.i18n; @@ -109,6 +109,11 @@ const withCustomFeatures = createHigherOrderComponent((BlockEdit) => { '', ); + storage.displayCopyright = + get(images, '[' + i + '].media_fields.field_copyright_enable.value.value', '') === 'on' + ? true + : false; + const mediaDetails = get(images, '[' + i + '].media_details'); if (mediaDetails) { @@ -146,13 +151,17 @@ const withCustomFeatures = createHigherOrderComponent((BlockEdit) => { {props.attributes.images.map((item, index) => ( - + + ))}