Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/inline-loader.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '07dbede220b80a24f3f811ea67147d4b');
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '39ba4cb29fd218134452ff60f8146083');
2 changes: 1 addition & 1 deletion js/inline-loader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion php/class-delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ public function filter_out_cloudinary( $content ) {
$original_url = $urls[ $result['public_id'] ];
$size = $this->media->get_size_from_url( $original_url );
$transformations = $this->media->get_transformations_from_string( $original_url );
$attachment_url = wp_get_attachment_image_url( $result['post_id'], $size );

if ( 'image' === $this->media->get_resource_type( $result['post_id'] ) ) {
$attachment_url = wp_get_attachment_image_url( $result['post_id'], $size );
} else {
$attachment_url = wp_get_attachment_url( $result['post_id'] );
}
if ( ! empty( $transformations ) ) {
$transformations = array_filter(
$transformations,
Expand Down
18 changes: 18 additions & 0 deletions php/media/class-video.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,17 @@ public function filter_video_block_pre_render( $block, $source_block ) {
} else {
$url = $this->media->cloudinary_url( $attachment_id );
$content = str_replace( $attributes['src'], $url, $content );

if ( ! empty( $attributes['poster'] ) ) {
// Maybe local URL.
if ( ! $this->media->is_cloudinary_url( $attributes['poster'] ) ) {
$post_id = attachment_url_to_postid( $attributes['poster'] );
$url = $this->media->cloudinary_url( $post_id );
if ( $url ) {
$content = str_replace( $attributes['poster'], $url, $content );
}
}
}
}
}
}
Expand Down Expand Up @@ -343,6 +354,13 @@ protected function build_video_embed( $attachment_id, $attributes = array(), $ov
// Set the poster.
if ( isset( $attributes['poster'] ) ) {
$poster_id = $this->media->get_public_id_from_url( $attributes['poster'] );

// Maybe poster is a local URL.
if ( empty( $poster_id ) ) {
$post_id = attachment_url_to_postid( $attributes['poster'] );
$poster_id = $this->media->get_public_id( $post_id );
}

if ( $poster_id ) {
$params['source']['poster']['public_id'] = $poster_id;
$poster_transformation = array(
Expand Down
2 changes: 1 addition & 1 deletion src/js/inline-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const CloudinaryLoader = {
width = image.width;
let height = Math.round( width / ratio );

while ( -1 === this.sizeBands.indexOf( width ) || ( height < image.height && width < maxSize ) ) {
while ( -1 === this.sizeBands.indexOf( width ) && height < image.height && width < maxSize ) {
width++;
height = Math.round( width / ratio );
}
Expand Down