@@ -308,19 +308,23 @@ public function filter_video_tags( $content ) {
308308 $ overwrite_transformations = true ;
309309 }
310310 $ cloudinary_url = $ this ->media ->cloudinary_url ( $ attachment_id , false , false , null , $ overwrite_transformations );
311- $ transformations = $ this ->media ->get_transformations_from_string ( $ cloudinary_url , 'video ' );
312- if ( ! empty ( $ transformations ) ) {
313- $ args ['transformation ' ] = $ transformations ;
314- }
315- $ video = wp_get_attachment_metadata ( $ attachment_id );
316- if ( $ this ->player_enabled () ) {
317- $ instance = $ this ->queue_video_config ( $ attachment_id , $ url , $ video ['fileformat ' ], $ args );
318- // Remove src and replace with an ID.
319- $ new_tag = str_replace ( 'src=" ' . $ url . '" ' , 'id="cloudinary-video- ' . esc_attr ( $ instance ) . '" ' , $ tag );
320- $ content = str_replace ( $ tag , $ new_tag , $ content );
321- } else {
322- // Just replace URL.
323- $ content = str_replace ( $ url , $ cloudinary_url , $ content );
311+ // Bail replacing the video URL for cases where it doesn't exist.
312+ // Cases are, for instance, when the file size is larger than the API limits — free accounts.
313+ if ( ! empty ( $ cloudinary_url ) ) {
314+ $ transformations = $ this ->media ->get_transformations_from_string ( $ cloudinary_url , 'video ' );
315+ if ( ! empty ( $ transformations ) ) {
316+ $ args ['transformation ' ] = $ transformations ;
317+ }
318+ $ video = wp_get_attachment_metadata ( $ attachment_id );
319+ if ( $ this ->player_enabled () ) {
320+ $ instance = $ this ->queue_video_config ( $ attachment_id , $ url , $ video ['fileformat ' ], $ args );
321+ // Remove src and replace with an ID.
322+ $ new_tag = str_replace ( 'src=" ' . $ url . '" ' , 'id="cloudinary-video- ' . esc_attr ( $ instance ) . '" ' , $ tag );
323+ $ content = str_replace ( $ tag , $ new_tag , $ content );
324+ } else {
325+ // Just replace URL.
326+ $ content = str_replace ( $ url , $ cloudinary_url , $ content );
327+ }
324328 }
325329 }
326330
0 commit comments