base-js-sw 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ import { __ } from '@wordpress/i18n';
9
9
  import { MediaUpload, MediaUploadCheck } from '@wordpress/blockEditor';
10
10
  import { PanelBody, Button } from '@wordpress/components';
11
11
  import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';
12
- const { siteDomain } = themeVars; // vars passed from enqueue_backend.php
12
+ const { siteDomain, isBedrock = true } = themeVars;
13
13
  import './ImagePicker.scss';
14
14
 
15
15
  export const ImagePicker = ({
@@ -40,7 +40,12 @@ export const ImagePicker = ({
40
40
  if (imageObject.url.endsWith('.svg')) {
41
41
  resizedImageUrl = imageObject.url;
42
42
  } else {
43
- let imageUrlMinusBase = imageObject.url.replace(siteDomain + '/app/uploads', ''); // remove base and directory
43
+ let pathToReplace = siteDomain + '/app/uploads';
44
+ if (!isBedrock) {
45
+ pathToReplace = siteDomain + '/wp-content/uploads';
46
+ }
47
+
48
+ let imageUrlMinusBase = imageObject.url.replace(pathToReplace, ''); // remove base and directory
44
49
  resizedImageUrl = siteDomain + '/' + imageOptionsString + imageUrlMinusBase;
45
50
  }
46
51
  }
@@ -124,7 +129,7 @@ export const ImagePickerPreview = ({
124
129
  height = 500,
125
130
  crop = true,
126
131
  imageRef = 'imageObject',
127
- buttonText = 'Select image'
132
+ buttonText = 'Select image',
128
133
  }) => {
129
134
 
130
135
  let componentClass = 'component-image-picker-preview';
@@ -156,7 +161,8 @@ export const ImagePickerPreview = ({
156
161
  // Check if the image domain matches the current site's domain
157
162
  if (imageURL.origin === siteURL.origin) {
158
163
  // Same domain: remove base directory
159
- let imageUrlMinusBase = imageObject.url.replace(siteDomain + '/app/uploads', '');
164
+ const baseDir = isBedrock ? '/app/uploads' : '/wp-content/uploads';
165
+ let imageUrlMinusBase = imageObject.url.replace(siteDomain + baseDir, '');
160
166
 
161
167
  if (imageObject.url.endsWith('.svg')) {
162
168
  resizedImageUrl = imageObject.url;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "base-js-sw",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Reusable Gutenberg block components for WordPress projects",
5
5
  "main": "index.js",
6
6
  "author": "Shape Works",