Skip to content

Commit 60a8690

Browse files
authored
Merge pull request #385 from cloudinary/uat
Uat
2 parents 43f43af + db1dc08 commit 60a8690

37 files changed

+1514
-524
lines changed

cloudinary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Cloudinary
44
* Plugin URI: https://cloudinary.com/documentation/wordpress_integration
55
* Description: With the Cloudinary plugin, you can upload and manage your media assets in the cloud, then deliver them to your users through a fast content delivery network, improving your website’s loading speed and overall user experience. Apply multiple transformations and take advantage of a full digital asset management solution without leaving WordPress.
6-
* Version: 2.6.0
6+
* Version: 2.7.0-RC-6
77
* Author: Cloudinary Ltd., XWP
88
* Author URI: https://cloudinary.com/
99
* License: GPLv2+

js/cloudinary.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/gallery-block.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-components/build-style/style.css', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '2695e94cb7e3a139b92189c7f3552ac8');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-components/build-style/style.css', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '95635dcdce3468c638dab46e572af7a3');

js/gallery-block.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/gallery.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-components/build-style/style.css', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '8208197bd5ef998a03d54b699afa3696');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'wp-block-editor', 'wp-components', 'wp-components/build-style/style.css', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '29099104bb87442e73de687aa973be61');

js/gallery.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/src/gallery-block/attributes.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,12 @@
7474
"selectedImages": {
7575
"type": "array",
7676
"default": []
77+
},
78+
"transformation_crop": {
79+
"type": "string",
80+
"default": "pad"
81+
},
82+
"transformation_background": {
83+
"type": "string"
7784
}
7885
}

js/src/gallery-block/controls.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Dot from 'dot-object';
22
import { __ } from '@wordpress/i18n';
33
import cloneDeep from 'lodash/cloneDeep';
4+
import Tippy from '@tippyjs/react';
45

56
import '@wordpress/components/build-style/style.css';
67

@@ -31,6 +32,8 @@ import {
3132
ZOOM_TRIGGER,
3233
ZOOM_TYPE,
3334
ZOOM_VIEWER_POSITION,
35+
RESIZE_CROP,
36+
PAD_STYLES,
3437
} from './options';
3538

3639
import Radio from './radio';
@@ -57,6 +60,15 @@ const Controls = ( { attributes, setAttributes, colors } ) => {
5760
? JSON.stringify( nestedAttrs.customSettings )
5861
: nestedAttrs.customSettings;
5962

63+
if ( ! attributes.transformation_crop ) {
64+
attributes.transformation_crop = 'pad';
65+
attributes.transformation_background = 'rgb:FFFFFF';
66+
}
67+
68+
if ( 'fill' === attributes.transformation_crop ) {
69+
delete attributes.transformation_background;
70+
}
71+
6072
return (
6173
<>
6274
<PanelBody title={ __( 'Layout', 'cloudinary' ) }>
@@ -144,6 +156,58 @@ const Controls = ( { attributes, setAttributes, colors } ) => {
144156
setAttributes( { aspectRatio: value } )
145157
}
146158
/>
159+
<p>
160+
<Tippy
161+
content={
162+
<span>
163+
{ __(
164+
'How to resize or crop images to fit the gallery. Pad adds padding around the image using the specified padding style. Fill crops the image from the center so it fills as much of the available space as possible.',
165+
'cloudinary'
166+
) }
167+
</span>
168+
}
169+
theme={ 'cloudinary' }
170+
arrow={ false }
171+
placement={ 'bottom-start' }
172+
>
173+
<div className="cld-ui-title">
174+
{ __( 'Resize/Crop Mode', 'cloudinary' ) }
175+
<span className="dashicons dashicons-info cld-tooltip"></span>
176+
</div>
177+
</Tippy>
178+
<ButtonGroup>
179+
{ RESIZE_CROP.map( ( type ) => (
180+
<Button
181+
key={ type.value + '-look-and-feel' }
182+
isDefault
183+
isPressed={
184+
type.value ===
185+
attributes.transformation_crop
186+
}
187+
onClick={ () =>
188+
setAttributes( {
189+
transformation_crop: type.value,
190+
transformation_background: null,
191+
} )
192+
}
193+
>
194+
{ type.label }
195+
</Button>
196+
) ) }
197+
</ButtonGroup>
198+
</p>
199+
{ 'pad' === attributes.transformation_crop && (
200+
<SelectControl
201+
label={ __( 'Pad style', 'cloudinary' ) }
202+
value={ attributes.transformation_background }
203+
options={ PAD_STYLES }
204+
onChange={ ( value ) => {
205+
setAttributes( {
206+
transformation_background: value,
207+
} );
208+
} }
209+
/>
210+
) }
147211
<p>{ __( 'Navigation', 'cloudinary' ) }</p>
148212
<p>
149213
<ButtonGroup>

js/src/gallery-block/edit.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const Edit = ( { setAttributes, attributes, className, isSelected } ) => {
4141
const [ loading, setLoading ] = useState( false );
4242

4343
const preparedAttributes = useMemo( () => {
44+
// Do not override block settings with defaults on existing ones.
45+
if ( 0 !== attributes.selectedImages.length ) {
46+
return attributes;
47+
}
48+
4449
const defaultAttrs = {};
4550

4651
// eslint-disable-next-line no-unused-vars

js/src/gallery-block/options.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export const CAROUSEL_LOCATION = [
9797
{ label: __( 'Left', 'cloudinary' ), value: 'left' },
9898
{ label: __( 'Right', 'cloudinary' ), value: 'right' },
9999
{ label: __( 'Top', 'cloudinary' ), value: 'top' },
100+
{ label: __( 'Bottom', 'cloudinary' ), value: 'bottom' },
100101
];
101102

102103
export const CAROUSEL_STYLE = [
@@ -189,3 +190,33 @@ export const MEDIA_ICON_SHAPE = [
189190
label: __( 'Square', 'cloudinary' ),
190191
},
191192
];
193+
194+
export const RESIZE_CROP = [
195+
{
196+
label: __( 'Pad', 'cloudinary' ),
197+
value: 'pad',
198+
},
199+
{
200+
label: __( 'Fill', 'cloudinary' ),
201+
value: 'fill',
202+
},
203+
];
204+
205+
export const PAD_STYLES = [
206+
{
207+
label: __( 'White padding', 'cloudinary' ),
208+
value: 'rgb:FFFFFF',
209+
},
210+
{
211+
label: __( 'Border color padding', 'cloudinary' ),
212+
value: 'auto',
213+
},
214+
{
215+
label: __( 'Predominant color padding', 'cloudinary' ),
216+
value: 'auto:predominant',
217+
},
218+
{
219+
label: __( 'Gradient fade padding', 'cloudinary' ),
220+
value: 'auto:predominant_gradient',
221+
},
222+
];

0 commit comments

Comments
 (0)