Hey there and thanks for this nifty little helper. I found it to be a great alternative to the somewhat blown media thing.
However, it would be awesome if the available video formats could be configured in the backend.
Right now I had to hack youtube.inc to add my desired dimensions manually, which is evil, of course.

In case anybody else needs to quickly add another size: just add your desired format to the array found in youtube_size_options() inside youtube.inc.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jenlampton’s picture

Assigned: Unassigned » jenlampton

This is reasonable, YouTube allows custom dimensions and I'd like the field formatter to do the same.

guschilds’s picture

Status: Active » Needs review
FileSize
5.2 KB

I too thank you for this module. Media and Media:YouTube was way more than I needed and this was perfect.

Like klickreflex, I needed to have more freedom with the video dimensions so I implemented the attached patch. It basically replaces all uses of youtube_size with youtube_width and youtube_height. Could probably remove a few existing functions if this code sticks. Also worth noting: I did not touch anything with thumbnail formatting. Anyway, happy to hear criticism.

For all using this module and/or patch: the dimensions are altered as field formatters.

Thanks again,
Gus

enzipher’s picture

Hey,

I needed this feature as well, however, I needed multiple size options so I added a textarea in the admin config where the user can enter an unlimited number of sizes.

From what I can tell guschilds patch in #2 only support one custom size.

There might be room for improvements, but I hope this patch can be of use.

Cheers,

guschilds’s picture

The patch I created allows the user to enter one size per View Mode per Content Type. The choices are not stored on the module settings page, but on the field formatter settings for a given field. To change the output video dimensions of a video field:

  1. Navigate to Structure > Content Types > Manage Fields (or admin/structure/types/manage/[content-type]/display)
  2. Set the YouTube video field's Format as "YouTube video"
  3. Click the gear to independently edit the width and the height of the output video

This is essentially how the dimensions are changed in the original module and in #3 patch as well, just providing free range rather than selection from a list of pre-defined choices (whether they be hardcoded into the module or configured on the settings page).

The downfall in my approach is that it relies on the data provider to get the dimensions of the desired aspect ratio correct for the embedded video to properly fill the video frame. Not convinced it is the better approach, but it is working well for me thus far.

enzipher’s picture

You are completely correct in that your patch support different dimensions. I never actually tried it, so excuse me for missing that. However, I personally prefer my approach in the way that you have all sizes in one place, and when editing the display settings there is no confusion what to enter, or in this case what to choose. My patch also supports Views, which as far as I can tell yours doesn't.

In any case we're all winners. Your patch works for you and my patch works for me, and everyone else can choose what they prefer. ;)

Cheers,

endless_wander’s picture

Status: Needs review » Reviewed & tested by the community

Thanks to guschilds and enzipher for these patches. I tried both and they work well for this. Would recommend something being added to the main module to support this feature...

B-Prod’s picture

Status: Reviewed & tested by the community » Needs review

Thanks, the patch works well. It only misses a "variable_del" call in the install file for the new introduced variable "youtube_sizes".

chefnelone’s picture

@guschilds: I'm trying to apply the patch you've posted in #2 but I get this error message:

Me-iMac:youtube me$ git apply -v youtube_field-video-dimension-formatters-1485078-2.patch

fatal: git diff header lacks filename information when removing 1 leading pathname components (line 5)

Is the patch older than the last version of the module?

Great module btw, thanks for sharing it!

guschilds’s picture

@chefnelone

It was the same code, but you are right, it wasn't properly applying to the fresh download.

I went ahead and rebuilt the patch from #2. I've also removed a bit more code that is no longer necessary when the field is sized in this way. It should work for you now with 'git apply -v youtube_field-video-dimension-formatters-1485078-9.patch'.

It applies cleanly, but you may get 3 whitespace-related errors due to a whitespace at the end of three lines that are outputting a long HTML string in theme_youtube_video() of youtube.theme.inc. If anyone has a better suggestion for formatting this it is welcome.

Thanks for bringing this up!

Gus

chefnelone’s picture

thanks!

AaronBauman’s picture

Status: Needs review » Needs work

Doesn't seem to be working -- the video stays the same size even after i change the settings.
The height and width variables are not being saved properly in the display settings.

also, now i'm getting a php warning:
Undefined index: youtube_size in youtube_field_formatter_view() (line 229 of ...youtube.module)

AaronBauman’s picture

correction: the values are being stored properly in display settings, they just aren't sent to the theme function.
this is correlated to the "youtube_size" notice mentioned previously.
line 229 "youtube_size" should be replaced with two lines for "youtube_height" and "youtoube_width"

guschilds’s picture

@aaronbauman

My apologies. I had this working properly in #2's patch but missed it when recently re-creating the patch.

I've replaced line 229 of youtube.module just as you've advised. The attached patch is identical to #9 aside from the addition mentioned in #12.

I tested it quickly and it seems to work as it should. Thanks for bringing it up. I'll get this right one of these days!

Gus

guschilds’s picture

Status: Needs work » Needs review
jenlampton’s picture

Status: Needs review » Needs work

I don't think I like the approach given in the latest patch.
I'd prefer to see a UI more like that on youtube.com for selecting image size.
Only local images are allowed.

We should add the custom option to the set-options that were available before. we should not replace the selected sizes with only the option for custom sizes.

jenlampton’s picture

Here's a solution that adds an additional option for a custom size.
What do you think of this?

guschilds’s picture

Status: Needs work » Needs review
FileSize
4.74 KB

I think #16 is the best idea that has come from this thread. I applied the patch and it works well.

I'm not trying to steal any thunder, but there was a whitespace issue on one line. I've fixed it in the attached patch. That is the only difference.

For others trying to apply this patch, it will not apply to 7.x-1.x-alpha2, but will to the most recent 7.x-1.x branch. I'd imagine it will likely become a part of that branch soon enough.

guschilds’s picture

FWIW, I would have marked #16 reviewed & tested by the community had I not removed the white space from one line and posted a new patch.

AaronBauman’s picture

+1 for #16 + #17

jenlampton’s picture

Status: Needs review » Reviewed & tested by the community

It sounds like aaronbauman meant to change the status.

jenlampton’s picture

Status: Reviewed & tested by the community » Fixed

fixed and committed! Thanks for the help everyone :)

Status: Fixed » Closed (fixed)

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