Skip to content

Commit df94007

Browse files
authored
Merge pull request #906 from cloudinary/improve/get_public_id
Improve `get_public_id`
2 parents 9c3a577 + 7bdc585 commit df94007

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

php/class-delivery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ protected function standardize_tag( $tag_element ) {
11791179
'resource_type' => $resource_type,
11801180
);
11811181

1182-
$tag_element['atts']['data-public-id'] = $this->plugin->get_component( 'connect' )->api->get_public_id( $tag_element['id'], '', $args );
1182+
$tag_element['atts']['data-public-id'] = $this->plugin->get_component( 'connect' )->api->get_public_id( $tag_element['id'], $args );
11831183

11841184
return $tag_element;
11851185
}

php/connect/class-api.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public function cloudinary_url( $public_id = null, $args = array(), $size = arra
314314
}
315315

316316
if ( $attachment_id ) {
317-
$public_id = $this->get_public_id( $attachment_id, $public_id, $args );
317+
$public_id = $this->get_public_id( $attachment_id, $args );
318318
}
319319

320320
$url_parts[] = $args['version'];
@@ -796,13 +796,12 @@ public function get_upload_prefix() {
796796
/**
797797
* Get the Cloudinary public_id.
798798
*
799-
* @param int $attachment_id The attachment ID.
800-
* @param null|string $original_public_id The original public ID.
801-
* @param array $args The args.
799+
* @param int $attachment_id The attachment ID.
800+
* @param array $args The args.
802801
*
803802
* @return string
804803
*/
805-
public function get_public_id( $attachment_id, $original_public_id = null, $args = array() ) {
804+
public function get_public_id( $attachment_id, $args = array() ) {
806805

807806
$relationship = Relationship::get_relationship( $attachment_id );
808807
$public_id = null;
@@ -849,13 +848,15 @@ public function get_public_id( $attachment_id, $original_public_id = null, $args
849848
* @hook cloudinary_seo_public_id
850849
* @since 3.1.5
851850
*
852-
* @param $public_id {string} The suffixed public_id.
853-
* @param $original_public_id {string} The original public_id.
854-
* @param $attachment_id {int} The attachment ID.
851+
* @param $sufix {string} The public_id suffix.
852+
* @param $relationship {Relationship} The relationship.
853+
* @param $attachment_id {int} The attachment ID.
855854
*
856855
* @return {string}
857856
*/
858-
$public_id = apply_filters( 'cloudinary_seo_public_id', "{$public_id}/{$filename}.{$relationship->format}", $original_public_id, $attachment_id );
857+
$suffix = apply_filters( 'cloudinary_seo_public_id', "{$filename}.{$relationship->format}", $relationship, $attachment_id );
858+
859+
$public_id .= "/{$suffix}";
859860
}
860861

861862
return $public_id;

0 commit comments

Comments
 (0)