Can this module display the youtube title as it currently does with the thumbnail and video?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guschilds’s picture

Status: Active » Needs review
FileSize
640 bytes

This module does not store the title of the YouTube video in the database and there aren't any plans to do so. However, you can use YouTube's API to get a video's title when given the video_id. I've attached a patch that adds a youtube_get_video_title_by_id() function to the module. Perhaps you can use this where you need the title. For example, once you've grabbed the video_id from the node object:

$video_id = YOUR_VIDEO_ID;
$video_title = youtube_get_video_title_by_id($video_id)

I got the code for this function from this StackOverflow answer. Not sure about this getting committed, but I hope it helps!

Thanks,
Gus

borgeous’s picture

this is awesome, will this also add the field in the display formatter box? along with youtube and thumbnail?

guschilds’s picture

It will not by default, nor is there an option to do so, but you can insert it yourself in one of a few ways:

  • using a preprocessor function and/or a custom template for the field, node, or view result (read more)
  • override theme_youtube_video() from youtube.theme.inc by pasting it into template.php and renaming it (read more)

Either one should allow you to wrap it in whatever HTML element you'd like.

guschilds’s picture

Attaching an update to the function in the previous patch, created while working on #2085749: Iframe missing title tag.

guschilds’s picture

Issue summary: View changes

grammar

guschilds’s picture

Title: Display Video Title » Provide function or ability to display YouTube video's title
Issue summary: View changes
Status: Needs review » Closed (won't fix)

Closing this because the function will not be committed to the module, as there are no plans to use it. The biggest downside to using it is adding an extra request every time this title is needed (unless caching was added). Perhaps if more interest is shown or use cases arise, it could be reconsidered. In the meantime, hopefully anyone needing this function will find it here (#4) and will be able to make us of it within their custom code.