Skip to content

Commit 65f3d22

Browse files
author
Marco Pereirinha
committed
Merge branch 'develop' into uat
2 parents 53fe2e9 + c494216 commit 65f3d22

File tree

11 files changed

+170
-42
lines changed

11 files changed

+170
-42
lines changed

js/inline-loader.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => '25ccbb8ce37353267420');
1+
<?php return array('dependencies' => array(), 'version' => '4e42165f1fda84e18ed5');

js/inline-loader.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.

package-lock.json

Lines changed: 25 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"minimist": "^1.2.6",
126126
"npm-run-all": "^4.1.5",
127127
"null-loader": "^4.0.1",
128-
"postcss": "^8.1.6",
128+
"postcss": "^8.4.31",
129129
"postcss-color-function": "^4.1.0",
130130
"postcss-import": "^13.0.0",
131131
"postcss-loader": "^4.0.4",

php/class-delivery.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,10 @@ public function convert_tags( $content, $context = 'view' ) {
10321032
$replacements = array_merge( $replacements, $aliases );
10331033
}
10341034

1035+
// Sort by length, so we replace the longest first and prevent early replacements.
1036+
$keys = array_map( 'strlen', array_keys( $replacements ) );
1037+
array_multisort( $keys, SORT_DESC, $replacements );
1038+
10351039
// Update the post meta cache.
10361040
if ( is_singular() ) {
10371041
$has_cache = array();
@@ -1140,7 +1144,7 @@ protected function standardize_tag( $tag_element ) {
11401144
$local_size = filesize( get_attached_file( $tag_element['id'] ) );
11411145
}
11421146
$remote_size = get_post_meta( $tag_element['id'], Sync::META_KEYS['remote_size'], true );
1143-
$tag_element['atts']['data-filesize'] = size_format( $local_size );
1147+
$tag_element['atts']['data-filesize'] = size_format( $local_size );
11441148
$tag_element['atts']['data-optsize'] = size_format( $remote_size );
11451149
$tag_element['atts']['data-optformat'] = get_post_meta( $tag_element['id'], Sync::META_KEYS['remote_format'], true );
11461150
if ( ! empty( $local_size ) && ! empty( $remote_size ) ) {
@@ -1154,6 +1158,29 @@ protected function standardize_tag( $tag_element ) {
11541158

11551159
$tag_element['atts']['data-version'] = $this->media->get_cloudinary_version( $tag_element['id'] );
11561160

1161+
/**
1162+
* Bypass Cloudinary's SEO URLs.
1163+
*
1164+
* @hook cloudinary_bypass_seo_url
1165+
* @since 3.1.5
1166+
*
1167+
* @param $bypass_seo_url {bool} Whether to bypass SEO URLs.
1168+
*
1169+
* @return {bool}
1170+
*/
1171+
$bypass_seo_url = apply_filters( 'cloudinary_bypass_seo_url', false );
1172+
1173+
$tag_element['atts']['data-seo'] = ! $bypass_seo_url;
1174+
1175+
$resource_type = in_array( $tag_element['type'], array( 'image', 'video' ), true ) ? $tag_element['type'] : 'raw';
1176+
1177+
$args = array(
1178+
'delivery' => $this->media->get_media_delivery( $tag_element['id'] ),
1179+
'resource_type' => $resource_type,
1180+
);
1181+
1182+
$tag_element['atts']['data-public-id'] = $this->plugin->get_component( 'connect' )->api->get_public_id( $tag_element['id'], '', $args );
1183+
11571184
return $tag_element;
11581185
}
11591186

@@ -1182,9 +1209,10 @@ public function rebuild_tag( $tag_element ) {
11821209
if ( apply_filters( 'cloudinary_apply_breakpoints', true ) ) {
11831210
$meta = wp_get_attachment_metadata( $tag_element['id'] );
11841211
if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
1212+
$relationship = Relationship::get_relationship( $tag_element['id'] );
11851213
// Check overwrite.
11861214
$meta['overwrite_transformations'] = $tag_element['overwrite_transformations'];
1187-
$meta['cloudinary_id'] = $tag_element['atts']['data-public-id'];
1215+
$meta['cloudinary_id'] = $relationship->public_id;
11881216
$meta['transformations'] = $tag_element['transformations'];
11891217
// Add new srcset.
11901218
$element = wp_image_add_srcset_and_sizes( $tag_element['original'], $meta, $tag_element['id'] );
@@ -1318,7 +1346,7 @@ public function parse_element( $element ) {
13181346
$tag_element['height'] = ! empty( $attributes['height'] ) ? $attributes['height'] : $item['height'];
13191347
$attributes['data-public-id'] = $public_id;
13201348
$tag_element['format'] = $item['format'];
1321-
1349+
13221350
if ( 'img' === $tag_element['tag'] ) {
13231351
// Check if this is a crop or a scale.
13241352
$has_size = $this->media->get_size_from_url( $this->sanitize_url( $raw_url ) );

php/class-media.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ public function cloudinary_url( $attachment_id, $size = array(), $transformation
13831383
'secure' => is_ssl(),
13841384
'version' => $this->get_cloudinary_version( $attachment_id ),
13851385
'resource_type' => $resource_type,
1386-
'delivery_type' => $delivery,
1386+
'delivery' => $delivery,
13871387
);
13881388
$set_size = array();
13891389
if ( 'upload' === $delivery ) {
@@ -1397,7 +1397,7 @@ public function cloudinary_url( $attachment_id, $size = array(), $transformation
13971397

13981398
// Make a copy as not to destroy the options in \Cloudinary::cloudinary_url().
13991399
$args = $pre_args;
1400-
$url = $this->plugin->components['connect']->api->cloudinary_url( $cloudinary_id, $args, $set_size );
1400+
$url = $this->plugin->components['connect']->api->cloudinary_url( $cloudinary_id, $args, $set_size, $attachment_id );
14011401

14021402
// Check if this type is a preview only type. i.e PDF.
14031403
if ( ! empty( $set_size ) && $this->is_preview_only( $attachment_id ) ) {

0 commit comments

Comments
 (0)