Skip to content

Commit 41cfe9d

Browse files
author
David Cramer
authored
Merge pull request #190 from cloudinary/fix/rc-3
add class with video ID in video block instead or url DB lookup.
2 parents 8fccd96 + 33bba11 commit 41cfe9d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-filter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public function get_video_shortcodes( $html ) {
9292
public function get_id_from_tag( $asset ) {
9393
$attachment_id = false;
9494
// Get attachment id from class name.
95-
if ( preg_match( '#class=["|\']?[^"\']*wp-image-([\d]+)[^"\']*["|\']?#i', $asset, $found ) ) {
96-
$attachment_id = intval( $found[1] );
95+
if ( preg_match( '#class=["|\']?[^"\']*(wp-image-|wp-video-)([\d]+)[^"\']*["|\']?#i', $asset, $found ) ) {
96+
$attachment_id = intval( $found[2] );
9797
}
9898

9999
return $attachment_id;

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function filter_video_tags( $content ) {
279279
if ( false === $url ) {
280280
continue;
281281
}
282-
$attachment_id = $this->media->get_id_from_url( $url );
282+
$attachment_id = $this->media->filter->get_id_from_tag( $tag );
283283
if ( empty( $attachment_id ) ) {
284284
continue; // Missing or no attachment ID found.
285285
}
@@ -450,6 +450,9 @@ public function filter_video_block_pre_render( $block, $source_block ) {
450450
if ( ! empty( $source_block['attrs']['overwrite_transformations'] ) ) {
451451
$classes .= ' cld-overwrite';
452452
}
453+
if ( ! empty( $source_block['attrs']['id'] ) ) {
454+
$classes .= ' wp-video-' . $source_block['attrs']['id'];
455+
}
453456
foreach ( $block['innerContent'] as &$content ) {
454457

455458
$video_tags = $this->media->filter->get_media_tags( $content );

0 commit comments

Comments
 (0)