Forum topic: thumbnail in custom template

hi,
i am trying to insert the thumbnail image for video files into a custom template, i just need to know how to extract the file path from the openpackage node, can someone explain how to do this?
thanks,
Joseph

for reference i'm currently using:

<?php
if ($node->type == 'openvideo')
{
      
$imageUrl = '/files/videos/image-cache/' . $node->field_videofile_0[0]['video_id'] . '_third_130x100.jpeg' ;
}
?>

but this is not enough as it assume the 1/3 thumbnail

There are functions in op_video that do this sort of thing. Try something like

<?php
$video
= _op_video_get_first_video($node);
echo
_op_video_render_preview_image($video, $width, $height, $extra, $image);
?>

$extra is an array of attributes for the img tag.
$image can be 'start' or 'third'.

There should really be a proper API in op_video for this.

Thanks Jonathan,
can $image be 'custom' as well, and how do I pull which is selected from the database ?

-joseph

Yeah - $image can also be 'custom'.

If you leave off the $image parameter, then the field setting is used.

thanks Jonathan,

I needed just the file path (to pass to a flash movie) so what I have now is:

<?php
if ($node->type == 'openvideo')
{
   
$op_thumb = "start";
   
$video = _op_video_get_first_video($node);
   
$op_thumb_pref = $video['preview_image']['preview_image'];
   
$height = 100; //manually overriding because am getting 400x300 default
   
$width = 130; //also this size fits in the flash container
   
_op_video_render_preview_image($video, $width, $height, $extra, $op_thumb_pref); //i thought calling this would create the right sized jpeg from the png
   
   
if ($op_thumb_pref == 'c') {  //preview_image type seems to be stored as the first letter only
       
$imageUrl = '/files/videos/image-cache/' . $node->field_videofile_0[0]['video_id'] . '_custom_' . $width . 'x' . $height . '.jpeg';
        } else {
            if (
$op_thumb_pref == 't') {
       
$imageUrl = '/files/videos/image-cache/' . $node->field_videofile_0[0]['video_id'] . '_third_' . $width . 'x' . $height . '.jpeg'
            } else {
       
$imageUrl = '/files/videos/image-cache/' . $node->field_videofile_0[0]['video_id'] . '_start_' . $width . 'x' . $height . '.jpeg'//assume start if all else fails
           
}
        }
?>

this code is in my themes teaser.tpl
does the image-cache get cleaned out every once and a while? because i had this working fine last week but today all the thumbnails are missing, and getting re-generated at 400x300 (thus the changes i've made today to try and force 130x100)
should _op_video_render_preview_image($video, $width, $height, $extra, $op_thumb_pref); create the "image-cache/212_custom_130x100.jpeg" file ?

-joseph

Try this:

<?php
if ($node->type == 'openvideo')
{
 
$video = _op_video_get_first_video($node);

//  $op_thumb = _op_video_get_preview_image($video);
 
$op_thumb = "start";

 
$height = 100; //manually overriding because am getting 400x300 default
 
$width = 130; //also this size fits in the flash container

 
$imageUrl = _op_video_render_image($video, $op_thumb, $width, $height);
?>

$op_thumb can be set to the default with _op_video_get_preview_image($video), or you can specify it directly, e.g. 'start'.

Yay!
thanks Jonathan, it's working a treat now

-joseph

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h1> <h2> <h3> <h4> <b>
  • Lines and paragraphs break automatically.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options