Skip to content

Commit 8a15102

Browse files
committed
Add a get overlay helper method
1 parent ab6fb17 commit 8a15102

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

php/class-relate.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static function update_transformations_overlay( $attachment_id, $overlay_
107107
return;
108108
}
109109

110-
$relationship->$save_type = json_encode( $overlay_data );
110+
$relationship->$save_type = wp_json_encode( $overlay_data );
111111
$relationship->save();
112112
}
113113

@@ -133,4 +133,26 @@ public static function get_transformations( $attachment_id, $as_string = false )
133133

134134
return $transformations;
135135
}
136+
137+
/**
138+
* Get overlay data for an asset.
139+
*
140+
* @param int $attachment_id The attachment ID.
141+
* @param string $overlay_type The type of overlay ('text_overlay' or 'image_overlay').
142+
*
143+
* @return string
144+
*/
145+
public static function get_overlay( $attachment_id, $overlay_type ) {
146+
$relationship = Relationship::get_relationship( $attachment_id );
147+
$overlay_data = $relationship->$overlay_type;
148+
149+
if ( ! empty( $overlay_data ) ) {
150+
$decoded = json_decode( $overlay_data, true );
151+
if ( is_array( $decoded ) && isset( $decoded['transformation'] ) ) {
152+
return $decoded['transformation'];
153+
}
154+
}
155+
156+
return '';
157+
}
136158
}

php/media/class-global-transformations.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ public function get_current_post() {
617617
public function transformations_column( $cols ) {
618618

619619
$custom = array(
620-
'cld_transformations' => __( 'Transformations', 'cloudinary' ),
620+
'cld_transformations' => __( 'Transformation Effects', 'cloudinary' ),
621621
);
622622
$offset = array_search( 'parent', array_keys( $cols ), true );
623623
if ( empty( $offset ) ) {
@@ -660,8 +660,18 @@ public function transformations_column_value( $column_name, $attachment_id ) {
660660
if ( ! empty( $item['data']['public_id'] ) ) {
661661
$text = __( 'Add transformations', 'cloudinary' );
662662
$transformations = Relate::get_transformations( $attachment_id, true );
663+
$text_overlay = Relate::get_overlay( $attachment_id, 'text_overlay' );
664+
$image_overlay = Relate::get_overlay( $attachment_id, 'image_overlay' );
665+
663666
if ( ! empty( $transformations ) ) {
664667
$text = $transformations;
668+
669+
if ( ! empty( $text_overlay ) ) {
670+
$text .= '/' . $text_overlay;
671+
}
672+
if ( ! empty( $image_overlay ) ) {
673+
$text .= '/' . $image_overlay;
674+
}
665675
}
666676
$args = array(
667677
'page' => 'cloudinary',

0 commit comments

Comments
 (0)