If i installed the module and test with a youtube Url the page say follow error.

Notice: Undefined index: host in video_embed_field_field_formatter_prepare_view() (Zeile 123 von .....\sites\all\modules\video_embed_field\video_embed_field.module).

I hope its can be fixed.

Thanks Lennard

Comments

jec006’s picture

Hey Lennard,

I will definitely look into that - would you mind posting the url (or at least the way that the youtube part looks - for example: http://youtube.com?v=... ?

That would help me reproduce and debug

Thanks,
Josh

Lennard’s picture

The url with i tested is http://www.youtube.com/watch?v=8HBNtSVFZ_c
its an normal youtube link.

Greets Lennard

eirik k.’s picture

I think I know what may be causing this bug. If you allow more than one value, eg. unlimited video fields, you may have empty Video URL fields on the edit screen. video_embed_field_field_formatter_prepare_view does not check if $parts is false (ie. no URL at all) before trying to get $parts['host'].

Lennard’s picture

You are right eirikkk :)

The solution for that is little changed in video_embed_field_field_formatter_prepare_view
in video_embed_field.module to:

<?php
/**
*  Implementation of hook_field_formatter_prepare_view
*  Prepare the view of the video embed - if the embed code doesn't exist, create it using the url
*/
function video_embed_field_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays){
 $handlers = video_embed_get_handlers();
 foreach($items as $delta=>$item_wrapper){
   foreach($item_wrapper as $key=>$item){
     if(!$item['embed_code']){
       $parts = parse_url($item['video_url']);
       if(isset( $parts['host'])){
         $host = $parts['host'];
       }
       if(stripos($host, 'www.') > -1){
         $host = substr($host, 4);
       }

       if(isset($handlers[$host]['function']) && function_exists($handlers[$host]['function'])){
         $items[$delta][$key]['embed_code'] = call_user_func($handlers[$host]['function'], $item['video_url']);
       } else {
         $items[$delta][$key]['embed_code'] = l($item['video_url'], $item['video_url']);
       }
     }
   }
   
 }
}
?>

Thanks eirikkk !

jec006’s picture

Status: Needs work » Fixed

Ok, I fixed this in 2 ways:

1. I updated the empty and validate functions to prevent bad data being sent to the prepare_view function - this will fix this in almost all situations
2. For double security, I am now checking that the parts array in the prepare_view.

You may need to resave your nodes to get everything right.

Here are the commits:
http://drupal.org/commitlog/commit/25834/6c24dcdb22f721a8c252ea140f8344b...
http://drupal.org/commitlog/commit/25834/cee243636cfecc5b414ad0033cd9f2d...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.