Skip to content

Commit 451d56c

Browse files
committed
Fix Reset State
1 parent f855ece commit 451d56c

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

js/asset-edit.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.

php/connect/class-api.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class Api {
112112
'e' => 'effect',
113113
'l' => 'overlay',
114114
'so' => 'start_offset',
115+
'co' => 'color',
115116
'eo' => 'end_offset',
116117
'du' => 'duration',
117118
'a' => 'angle',

php/media/class-global-transformations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ public function transformations_column_value( $column_name, $attachment_id ) {
658658

659659
$item = $this->media->plugin->get_component( 'assets' )->get_asset( $attachment_id, 'dataset' );
660660
if ( ! empty( $item['data']['public_id'] ) ) {
661-
$text = __( 'Add effects', 'cloudinary' );
661+
$text = __( 'Add Effects', 'cloudinary' );
662662
$transformations = Relate::get_transformations( $attachment_id, true );
663663
$text_overlay = Relate::get_overlay( $attachment_id, 'text_overlay' );
664664
$image_overlay = Relate::get_overlay( $attachment_id, 'image_overlay' );
@@ -670,7 +670,7 @@ public function transformations_column_value( $column_name, $attachment_id ) {
670670
$link = add_query_arg( $args, 'admin.php' );
671671

672672
if ( ! empty( $transformations ) || ! empty( $text_overlay ) || ! empty( $image_overlay ) ) {
673-
$text = __( 'Edit effects', 'cloudinary' );
673+
$text = __( 'Edit Effects', 'cloudinary' );
674674
}
675675
?>
676676
<a href="<?php echo esc_url( $link ); ?>" class="cld_transformations__icons">

src/js/asset-edit.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ const AssetEdit = {
6363
}
6464

6565
this.isVideo = item?.type === 'video';
66-
67-
if( this.isVideo ) {
68-
this.publicId = item?.data?.public_id;
69-
} else {
70-
this.publicId = '/' + item.file.split('/').slice(-2).join('/');
71-
}
66+
this.publicId = '/' + item.file.split('/').slice(-2).join('/');
7267

7368
// Set up centralized text overlay mapping as a property
7469
this.textOverlayMap = [
@@ -99,18 +94,18 @@ const AssetEdit = {
9994
this.setOverlayInputs(this.textOverlayMap, textOverlayData);
10095
this.setOverlayInputs(this.imageOverlayMap, imageOverlayData);
10196
// Init components.
102-
this.initPreview();
97+
this.initPreview(item);
10398
this.initEditor();
10499
this.initGravityGrid( 'edit-overlay-grid-text', textOverlayData );
105100
this.initGravityGrid( 'edit-overlay-grid-image', imageOverlayData );
106101
this.initImageSelect();
107102
this.initRemoveOverlayButtons();
108103
},
109-
initPreview() {
104+
initPreview(item) {
110105
if ( this.isVideo ) {
111106
this.preview = VideoAssetPreview.init();
112107
this.wrap.appendChild( this.preview.createPreview( 480, 360 ) );
113-
this.preview.setPublicId( this.publicId );
108+
this.preview.setPublicId( item?.data?.public_id );
114109
this.preview.setSrc( this.buildSrc(), true );
115110
} else {
116111
this.preview = AssetPreview.init();
@@ -414,11 +409,12 @@ const AssetEdit = {
414409
return placementQualifiers.length > 0 ? ',' + placementQualifiers.join(',') : '';
415410
},
416411
buildImageOverlay() {
417-
if (!this.imageOverlayPublicIdInput || !this.imageOverlayPublicIdInput.value.trim()) {
412+
const imageId = this.imageOverlayPublicIdInput.value.trim().replace(/\//g, ':');
413+
414+
if ( !imageId ) {
418415
return '';
419416
}
420417

421-
const imageId = this.imageOverlayPublicIdInput.value.trim().replace(/\//g, ':');
422418
let imageLayerDefinition = `l_${imageId}`;
423419

424420
let transformations = [];

src/js/components/video-asset-preview.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,19 @@ const VideoAssetPreview = {
7777
fluid: true,
7878
controls: true,
7979
} );
80-
81-
// Set initial source immediately
82-
if ( this.publicId ) {
83-
this.player.source( this.publicId );
84-
}
8580
}
8681
},
8782

8883
setSrc( src, load = false ) {
8984
this.preview.style.opacity = 0.6;
9085
if ( load ) {
9186
this.apply.style.display = 'none';
87+
88+
// Ensure player is initialized before updating
89+
if ( ! this.player ) {
90+
this.initPlayer();
91+
}
92+
9293
this.updatePlayer( src );
9394
} else {
9495
this.apply.style.display = 'block';
@@ -112,6 +113,7 @@ const VideoAssetPreview = {
112113
this.player.source( sourceConfig );
113114
this.preview.style.opacity = 1;
114115
},
116+
115117
reset( src ) {
116118
this.setSrc( src, false );
117119
},

0 commit comments

Comments
 (0)