Hi,
I would like to use a same file (video) in two different articles:
The video file is already located in a folder video (with subfolder) and fetched through a kirbytag as follows in its original content folder
(video: xx.mp4 poster: xx.png)
Let’s assume that I want to use it again in a different article with kirbytag.
Is it possible (without copy the same file in the new content folder) and with what kind of syntax for kirbytag ?
Thank you
Yes, you can add the path to the page with the video
(video: video/subpage/xx.mp4 poster: video/subpage/xx.png)
Thank you for the swift answer.
It works well with the video (without poster)
but when I add the poster parameter I got the following error message:
Whoops \ Exception \ ErrorException (E_ERROR) Call to a member function url() on string
with the following highlighted line:
$poster_attr = ($poster) ? ' poster="'. $poster->url() .'"' : '';
The video tag is not a default Kirbytag? Check how the poster URL is created, you might have to adapt that.
Well, this line from the tag looks for the poster in the current page:
if ( $poster = $tag->page()->images()->find($tag->attr('poster'))) {
$args['poster'] = $poster;
}
You need to change that.
OK, but frankly, I have no idea on how to do it !
Sorry from a newbie
Try this instead of the lines above:
if ( $poster = $tag->file($tag->attr('poster'))) {
$args['poster'] = $poster;
}
You’ve been around for awhile .
Perfect ! it works with this modification