When trying to echo a custom function, I find an issue when using the following code on a text block:
{echo:get_video_thumbnail({mb_lessons_lesson__video_id})}
The output is:
<img class="css-filter size-medium_large" src="https://img.youtube.com/vi/mb_lessons_lesson__video_id/maxresdefault.jpg" alt="">
It is returning mb_lessons_lesson__video_id
instead of the dynamic value. (broken thumbnail in the video below).
However, the function returns the correct value when run using the Code element as:
<?php
$video_id = rwmb_meta( 'lesson__video_id' );
$video_url = get_video_thumbnail($video_id);
$video_thumbnail = '<figure class="brxe-ixdwfo brxe-image lesson-card__thumbnail outlined tag"><img class="css-filter size-medium_large" src='.$video_url.'></figure>';
echo $video_thumbnail;
?>
The actual function Iām using is:
function get_video_thumbnail($video_id) {
// set the default Thumbnail
$youtube_thumbnail_url = '/wp-content/uploads/Horizontal-Big.svg';
// get the Youtube Thumbnail
if ($video_id) {
$youtube_thumbnail_url = 'https://img.youtube.com/vi/'.$video_id.'/maxresdefault.jpg';
}
// WP Featured Image always overights the Youtube Thumbnail
if (has_post_thumbnail()) {
$youtube_thumbnail_url = get_the_post_thumbnail_url();
}
return $youtube_thumbnail_url;
}
Am I missing something? Is it something on the function, I tried to keep it as simple as possible or is this a bug on the text element in Bricks?
Thanks for your assistance.