From cfbb860bf92c31199be5aaf13f61a0664260d0a1 Mon Sep 17 00:00:00 2001 From: Jeremy Rangel Date: Thu, 19 Dec 2024 01:23:40 -0800 Subject: [PATCH] Changes to theme.json and gallery --- .../lcp-gallery/assets/css/lcp-gallery.css | 2 - .../blocks/lcp-gallery/assets/fonts/lg.woff2 | Bin 0 -> 2332 bytes includes/blocks/lcp-gallery/lcp-gallery.php | 5 +- includes/blocks/lcp-gallery/src/block.json | 19 ++++++ includes/blocks/lcp-gallery/src/edit.js | 61 ++++++++++-------- includes/blocks/lcp-gallery/src/style.scss | 2 + theme.json | 4 +- 7 files changed, 58 insertions(+), 35 deletions(-) delete mode 100644 includes/blocks/lcp-gallery/assets/css/lcp-gallery.css create mode 100644 includes/blocks/lcp-gallery/assets/fonts/lg.woff2 diff --git a/includes/blocks/lcp-gallery/assets/css/lcp-gallery.css b/includes/blocks/lcp-gallery/assets/css/lcp-gallery.css deleted file mode 100644 index 4b42641..0000000 --- a/includes/blocks/lcp-gallery/assets/css/lcp-gallery.css +++ /dev/null @@ -1,2 +0,0 @@ -.admin-bar .lg-outer {top:32px;height:calc(100% - 32px)!important} - diff --git a/includes/blocks/lcp-gallery/assets/fonts/lg.woff2 b/includes/blocks/lcp-gallery/assets/fonts/lg.woff2 new file mode 100644 index 0000000000000000000000000000000000000000..2c2e289260bf80880c447749205a7024c34310f0 GIT binary patch literal 2332 zcmV+%3FG#6Pew8T0RR9100|rb3jhEB01}7*00_+h0RR9100000000000000000000 z00006U;u$65eN#LES5?OIsgGS0we=)1Rw>1N(UetsSW_<=W(-oKMAExFsmpPS1K05 zm`JkguSY3=L2BQ9_!?p4ex41!yLOc&r zDT^p(Lo)AyuQlo9HLa2 zByzBWk}@|mNkOuaW+ht7^5wbI?CAO*9J5*jr_QF)i!&HbG#?g{+ddf%B->T{L(HqH&)%|{kM!vaiGD2Wk9^HhF(ny5FXcdS-1k6z*iIF(Do?5A8 zN6jh51JpV{W!W1?#U56Yi%GK;fTGvY`Ex;v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0z(0VMg;KkgbEo4~mUH~pO5l?vLTezY|&tu%iGVZ&~wX_mmvWmQm&hN7E= z!09nKV6dMN+#VwU3TO)P@uPJlMA$IX0})}EWz=IZkiZ9o`}jd3zz1Rkpn;VX0)BiW z5(*)1+eX+18{Z_p?$wA5ZEJV_rZMM0Gwg&NurFE%v|a;VzXw*^K&Ex}`ZaJ^s&9j} zk<`gWyzw8}ZZJPP7nr1my|CGh7|Mri$Q{@q89y~{IrIgCk@oMJR>L0mnF9_D0000L C#$m<) literal 0 HcmV?d00001 diff --git a/includes/blocks/lcp-gallery/lcp-gallery.php b/includes/blocks/lcp-gallery/lcp-gallery.php index fa996ab..9646257 100644 --- a/includes/blocks/lcp-gallery/lcp-gallery.php +++ b/includes/blocks/lcp-gallery/lcp-gallery.php @@ -156,9 +156,7 @@ function get_gallery_items_data($media_ids) { $alt_text = get_post_meta($media_id, '_wp_attachment_image_alt', true); // Use a fallback for alt text if it's empty - if (empty($alt_text)) { - $alt_text = 'No alt text available'; - } + // Add the gallery item to the array $gallery_items[] = array( @@ -444,7 +442,6 @@ add_action( 'init', 'lcp_gallery_block_init' ); /* Enqueue scripts and styles */ function enqueue_lightgallery_scripts() { // Enqueue styles - wp_enqueue_style('lcp-gallery', get_template_directory_uri() . '/includes/blocks/lcp-gallery/assets/css/lcp-gallery.css'); wp_enqueue_style('lightgallery-css', get_template_directory_uri() . '/includes/blocks/lcp-gallery/assets/css/lightgallery-bundle.min.css'); wp_enqueue_style('lg-transitions-css', get_template_directory_uri() . '/includes/blocks/lcp-gallery/assets/css/lg-transitions.css'); diff --git a/includes/blocks/lcp-gallery/src/block.json b/includes/blocks/lcp-gallery/src/block.json index 5c76ac9..ccf4f50 100644 --- a/includes/blocks/lcp-gallery/src/block.json +++ b/includes/blocks/lcp-gallery/src/block.json @@ -43,6 +43,21 @@ "fullScreen": false, "autoplay": false, "download": false, + "loop": true, + "closeOnTap": true, + "enableDrag": true, + "enableSwipe": true, + "escKey": true, + "getCaptionFromTitleOrAlt ": true, + "hideBarsDelay": 0, + "hideControlOnEnd": false, + "hideScrollbar ": false, + + + + + "controls": true, + "counter": true, "container": "", "closable": true, "zoomFromOrigin": false, @@ -326,6 +341,10 @@ "numberOfSlideItemsInDom": { "type": "number", "default": 10 + }, + "galleryCustomStyles": { + "type": "string", + "default": "" } }, diff --git a/includes/blocks/lcp-gallery/src/edit.js b/includes/blocks/lcp-gallery/src/edit.js index 41311c7..e5fb534 100644 --- a/includes/blocks/lcp-gallery/src/edit.js +++ b/includes/blocks/lcp-gallery/src/edit.js @@ -11,7 +11,9 @@ import { __experimentalNumberControl as NumberControl, __experimentalUnitControl as UnitControl, TabPanel, - __experimentalBorderControl as BorderControl + __experimentalBorderControl as BorderControl, + TextareaControl, + Popover } from '@wordpress/components'; import metadata from './block.json'; import './editor.scss'; @@ -33,6 +35,7 @@ const aspectRatioOptions = [ { value: '4-5', label: __('4:5', metadata.textdomain) }, { value: '2-3', label: __('2:3', metadata.textdomain) } ]; + // Check if JetEngine or ACF/SCF are activated and get their gallery field data const { apiFetch } = wp; @@ -116,7 +119,7 @@ export default function Edit(props) { thumbnailActiveStyle, showCaptions, zoomFromOrigin, - + galleryCustomStyles, lgSettings } = attributes; @@ -358,41 +361,26 @@ const { isTemplate, postType, postId } = useSelect((select) => { {/* Display Settings */} - { // Update the initialLayout attribute - setAttributes({ - initialLayout: newValue, - lgSettings: { - ...attributes.lgSettings, // Preserve existing lgSettings - closable: false , // Inline gallery should not be closeable - - } + setAttributes({ + initialLayout: newValue, + lgSettings: { + ...attributes.lgSettings, // Preserve existing lgSettings + closable: newValue !== 'inline', // Set closable based on the layout choice + showMaximizeIcon: newValue === 'inline', // Show maximize icon only if 'inline' is selected + } }); - }} + }} options={[ { value: 'inline', label: __('Inline', metadata.textdomain) }, { value: 'grid', label: __('Grid', metadata.textdomain) }, - // { value: 'justified', label: __('Justified', metadata.textdomain) }, Add later version { value: 'button', label: __('Button', metadata.textdomain) } ]} /> - {/* Include option to show maximize icon if inline gallery */} - {attributes.initialLayout === 'inline' && ( - setAttributes({ - lgSettings: { - ...attributes.lgSettings, // Preserve existing lgSettings - showMaximizeIcon: true, // Set the showMaximizeIcon based on the toggle - } - })} - /> - )} - setAttributes({ includePostThumbnail: isChecked })} @@ -469,7 +457,7 @@ const { isTemplate, postType, postId } = useSelect((select) => { {initialLayout !== 'inline' && ( setAttributes({ maxInitialItems: newValue })} + onChange={(newValue) => setAttributes({ maxInitialItems: 1})} value={maxInitialItems} isShiftStepEnabled shiftStep={1} @@ -479,6 +467,20 @@ const { isTemplate, postType, postId } = useSelect((select) => { {/* Gallery Settings */} + {/* Include option to show maximize icon if inline gallery */} + {attributes.initialLayout === 'inline' && ( + setAttributes({ + lgSettings: { + ...attributes.lgSettings, // Preserve existing lgSettings + showMaximizeIcon: true, // Set the showMaximizeIcon based on the toggle + } + })} + /> + )} + {/* Dynamic Settings */} { /> )} + + ); } }} + + + diff --git a/includes/blocks/lcp-gallery/src/style.scss b/includes/blocks/lcp-gallery/src/style.scss index 147208b..65b83c2 100644 --- a/includes/blocks/lcp-gallery/src/style.scss +++ b/includes/blocks/lcp-gallery/src/style.scss @@ -13,6 +13,8 @@ +.admin-bar .lg-container:not(.lg-inline) .lg-outer {top:32px;height:calc(100% - 32px)!important} + diff --git a/theme.json b/theme.json index 62d97b7..d5624df 100644 --- a/theme.json +++ b/theme.json @@ -56,8 +56,8 @@ ] }, "layout": { - "contentSize": "645px", - "wideSize": "1340px" + "contentSize": "1140px", + "wideSize": "1440px" }, "spacing": { "defaultSpacingSizes": false,