The youtube formatter module is a simple textfield display formatter, wich offers tree diffrent display types. A preview image in a defined image_style of the video, the embeded video via iframe, and a colorbox integration. Further informations on the projectpage.
The display of the images/videos are precise customizeable. Because a simple text field is used, there is no need to add a new fieldtype. It's easy to use beacause it uses the standard embeded youtubequicklink you get, if you push the share button on youtube (http://youtu.be/videoID)

Projectpage: http://drupal.org/sandbox/Hydra/1404188
Drupal Version: 7
Git reposetory: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/Hydra/1404188.git

Comments

thantthet’s picture

Status: Needs review » Needs work

You have some issues with coding guideline. You can see drupal coding guideline issue at http://ventral.org/pareview/httpgitdrupalorgsandboxhydra1404188git

and you will have to work in separate git branch rather than in master branch. more information http://drupal.org/node/1127732

hydra’s picture

Status: Needs work » Needs review

Thx for reviewing my module!
I fixed all the issues the tracker told me and switched to a seperate branch.

rade’s picture

Status: Needs review » Needs work

- You need to provide a non-maintainer URL to the repo and to the correct branch.

Manual review of branch 7.x-1.x:
- youtube_formatter_field_formatter_request_youtube_uri(): If $value does not contain a valid URL but just some text, a broken image is rendered and I get this notice:
Notice: Undefined offset: 3 in youtube_formatter_field_formatter_request_youtube_uri() (line 221 of /Users/Rade/workspace/d7/sites/all/modules/custom/youtube_formatter/youtube_formatter.module).
- Even though I set "Show in HD" to Yes the video's don't play in HD by default. Tried with videos that have both 720 and 1080 versions available.

Otherwise seems like a good module! There are however a few similar modules. Please describe how your module differs from the modules below. This could also be added on your project page under the title "Similar modules".
http://drupal.org/project/media_youtube
http://drupal.org/project/video_filter

hydra’s picture

Hey Rade,
thank you for reviewing my module!
I added some checks for the url input before rendering broken images or videos. The Notice doesnt appear anymore, broken links are simply not rendered anymore.
About the HD settings, you need to adjust the resolutsion of the VIdeo as well, I added some usefull descriptions to the settings, so the user better understands how to set them.
I also added the similar modules to the modules page.
The youtube_formatter simply provides a field_formatter, which menas there is no additional field like wich an embeded media field and there are no other modules required. It's based on the cores text_field, what makes it very lightweight. In case you only need to display some youtubevideos in youre articles this is the fastest and lightweightest method to do this.

hydra’s picture

Status: Needs work » Needs review

Would it be possible for someone to take a look at the actual progress :) Thanks

ANDiTKO’s picture

Hello Hydra! Great job, but you need to tweak this module a little bit to make it even better.

Manual review:
1) The HD option dose not work. I added a video that supports 1080p with setting "Dimensions: 1280x720, Play in HD: Yes" and video plays in 480p . After doing a research on this problem i found that your code is ok, but youtube is trying to play it smart and disable the HD embed feature. Please read this and this. In simple words the only way to embed HD is to use the old embed code and force the youtube player API version to 2 (then add the hd=1 parameter). I even tried to add a 1920x1080 iframe but the video was still playing in 480p.
2) Add the option to autoplay the embed video. Its not that hard and its very useful. But if you do that make an if statement that will check if there are other videos on the page and only autostart the first video.
3) Add support for youtube playlists.

Overall its a great module but i the following modules do the same job:
http://drupal.org/project/media_youtube
http://drupal.org/project/video_filter
http://drupal.org/project/youtube (which is pretty similar with yours but has views integration)

If you plan to have success with your project you must add more features than the modules shown above. Good luck!

hydra’s picture

First of all, thank you very much ANDiTKO for reviewing my module. I realy appreciate the research work you have done. Sadly I must tell, that I knew about the AS3 issue not supporting forcing the HD playing in smaller resolutions.
Like you suggested, I tried implementing the AS2 version, wich should still support the hd function (youtube api docu), but oviously, they don't! It's the same like in AS2, the HD only forced, when the resolution is hight enougth. I don't know why this didn't work for you, but I tested it with several HD ready videos from youtube. Resume: the HD option is obsolete, so I kicked it and replaced it with a nice autoplay function for the first video like you suggested, it's a nice feature. Also I added support for playlists!

The intention behind the module was to have a lightweight method to simply add youtubevideos without big dependencies. The media_youtube module depends on media and the youtube module provides an extra field. Because youtube_formatter is a field_formatter, it has build in views support as well! Additionally it has native colorbox support, so it is possible to have a prview image of the youtube video and onclick on the image the video opens in a colorbox! This is a very usual usecase, and this is what makes the diference! It covers most usecases involving youtube. More features only will cost peformance.

lva’s picture

Status: Needs review » Needs work

Hi Hydra,

The automatic review shows some small formatting issues: http://ventral.org/pareview/httpgitdrupalorgsandboxhydra1404188git

I have also performed a manual review:

  • I see an issue in function youtube_formatter_field_formatter_youtube_colorbox(). The $settings['safe_value'] can already be a URL which contains the "?" character (see line 281 in the case of a playlist). On line 89 you append another "?" to the URL. A possible fix could be like this:
    • In function youtube_formatter_field_formatter_get_settings(): In case of a playlist, don't add the "?list=$id" to the URL, but add it to the $parameters array.
    • In the same function, don't use drupal_http_build_query() yet, but pass the $parameters array as follows $new_settings['query'] = $parameters;
    • In function youtube_formatter_field_formatter_youtube_colorbox(), replace line 89 with the following:

      $settings['query'] = array_merge(
        $settings['query'],
        array(
          'width' => $settings['width'],
          'height' => $settings['height'],
          'iframe' => true,
        ),
      );
      $video_uri = url($settings['safe_value'], array('query' => $settings['query']));

      Also note that instead of building $video_uri with the url function, you can also do everyting the l() function like l('your text', $settings['safe_value'], array('html' => TRUE, 'attributes' => array('class' => 'colorbox-load'), 'query' => $settings['query']));

  • Same thing on line 122: use the url() function to build the URL instead of concatenating safe_value and query.
  • Line 150: use t() around the description to allow translation.

For the rest I don't immediately see any issues with your code.

hydra’s picture

Status: Needs work » Needs review

Thanks for reviewing! I relay was happy about your suggestions and tryed them out and implemented them the best I could. Ventral is still telling me I have two codingstyle issues, but it seems to be a bug. I did both twice and nothing happend.

benjy’s picture

Status: Needs review » Needs work

Hi Hydra,

  • Please change line endings in your IDE to "Unix line endings only".
  • I wouldn't worry about the short comment error it seems to be a mistake. You could refactor the comment if you want rid of it.
  • It would be nice if each of your functions had a little description
  • You should add a hook_help()
  • Line 54 of youtube_formatter.module you have a redundant assignment $settings = $display['settings']
  • Line 254 has a redundant assignment. $file = file_save($file);
  • Your comments seem to have a few typos. I know english may not be your first language so ill try point them out. Line 237 "preview", Line 266 "invalid", Line 283 "Helper function" , Line 295 "auto play", Line 189 "Auto play"
  • Line 121 Them ternary operations seem to be getting a little hard for everyone to read? Only my opinion though.

Once they've been fixed up I think it's looking pretty good :).

Nice module.

klausi’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

hydra’s picture

Status: Closed (won't fix) » Needs review

I really do appreciate your review, benjy, and it's the wrong way to show this in not reacting on this issue, I do feel sorry for that.

I tried applying your feedback, big thanks goes to the typo corrections, your right it's not my first language and I'm glad about to be corrected!
About you concerns about the hard to read operations, this was generated by the custom_formatters module... I think it's ok to leave it like that, because it's apparent whats going to happen there.

Next try!

klausi’s picture

We are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

sardbaba’s picture

Status: Needs review » Needs work

Hi Hydra,

really nice module! I like the easy way in which it can be used.

the automated review shows some errors: http://ventral.org/pareview/httpgitdrupalorgsandboxhydra1404188git-7x-1x, but I don't see any problem with that.

I manually reviewed your module:

1) Please set the right git url at "git clone --branch 7.x-1.x http://git.drupal.org/sandbox/Hydra/1404188.git youtube_formatter" in the Issue Summary of this page and in the project page
2) You should define @param and @return in the function definition: this seems to be optional (see http://drupal.org/node/1792992) but I think it is a good practice.
3) In youtube_formatter_help (youtube_formatter.module, row #15) you get $current_theme without using it: please remove this row or use the value.

I also tested your module and the "Youtube video" format works really good.

Instead with "Youtube image" format I can't make it to work: please double check it.
If I inspect the dom, I can see this URL:
http://mysite.local/sites/default/files/styles/medium/http/img.youtube.com/vi/TZLwfyVYJJw/0.jpg
Maybe it should be http://img.youtube.com/vi/TZLwfyVYJJw/0.jpg?

Cheers and good luck!

2pha’s picture

Sounds very similar to the youtube field module http://drupal.org/project/youtube

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

I'm a robot and this is an automated message from Project Applications Scraper.

PA robot’s picture

Issue summary: View changes

changed clone url to non maintiner