Hi Genis,
The bfe_video_thumbnails.py was a fictive name that I gave to the new
element that you would need to create if you wish to display the thumbnails.
It will need to return the thumbnails attached to the record. Creating a
new bibformat element is quite easy, some documentation can be found
here:
<http://invenio-demo.cern.ch/help/admin/bibformat-admin-guide#codeFormatElement>
(I've also attached a small example, containing the code from my
previous email)
Then, you would need to use this new format element in the format
template used for the videos, by adding something like
<BFE_VIDEO_THUMBNAILS /> in the template.
Best regards,
Ludmila
On 02/01/2014 04:21 PM, Genis Musulmanbekov wrote:
Hi Ludmila,
I'm not sure exactly in what way you would like to use the thumbnails. In
the vanilla Invenio this is left >at the decision of each administrator.
For CDS, we are just displaying the thumbnails under the video, for easy
preview.
If you wish to display the thumbnails somewhere on the record page, you
will need to update the detailed >format: Video_HTML_detailed.bft, by adding
a new format element: bfe_video_thumbnails.py, for example
The new format element (all format elements already defined can be found in
modules/bibformat/lib/elements/) will have to return the html for the list
of thumbnails attached to the >record (styled as you wish).
Where can I get that element 'bfe_video_thumbnails.py'? I couldn't find it
neither in installation package (invenio v.1.1.2) nor in invenio repository
(http://invenio-software.org/browser).
Genis
To retrieve the list if thumbnails, would be something in these lines:
$ipython
In [1]: from invenio.bibdocfile import BibRecDocs
In [2]: brd = BibRecDocs(107)
In [3]: thumbnails = [item.get_url() for item in brd.list_latest_files() if
item.subformat=='small'] #list of all the thumbnail URLs attached to this
record
The simples way to display them would be (you can add the style for the
video_thumb class in the css)
In [4]: out = ''.join(['<img class="video_thumb" src="%s" />' %item for item
in thumbnails])
Hope this helps!
Best regards,
Ludmila
from invenio.bibdocfile import BibRecDocs
def format_element(bfo):
"""
Prints a list of thumbnails
"""
brd = BibRecDocs(bfo.recID)
#list of all the thumbnail URLs attached to this record
thumbnails = [item.get_url() for item in brd.list_latest_files() \
if item.subformat == 'small']
out = ''.join(['<img class="video_thumb" src="%s" />' %item \
for item in thumbnails])
return out
def escape_values(bfo):
"""
Called by BibFormat in order to check if output of this element
should be escaped.
"""
return 0