Hi,

Is there support for tokens in the file path field for uploaded videos?
If there isn't can we add support for them?

Thank you

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jorrit’s picture

Status: Active » Postponed (maintainer needs more info)

Have you taken a look at the File field paths module? If you're going to use it in combination with Amazon S3, you must apply this patch: #1556160: rmdir should refuse to delete the directory when it is not empty.

Alexander Allen’s picture

I will take the Field field paths module into consideration.

However as an afterthought I wonder, why does image upload fields support token out of the box? Is it because there is an image module in core? Or is the image upload token support added by the contrib image module? If it's the image module adding token support, then I think it would be useful for the Video module to do the same (eventually). Regardless of the case, Field field paths is an acceptable short-term solution, so thank you for the recommendation!

Alexander Allen’s picture

Also when using filefield_paths, which adds support for tokens on the image module (don't know if they refer to core or contrib), would it conflict with existing token support for the image module? I know this is not related to the video module itself, just merely to your recommendation. I'm just putting the question out there just in case.

Thanks

Jorrit’s picture

I am not sure about the token support of the image module. What image contrib module are you referring to?

Alexander Allen’s picture

This is the module that is providing the image fields that I'm using: http://drupal.org/project/image

I searched for "token" on this contrib module and found the following:
image_import.pages.inc - .../sites/all/modules/contrib/image/contrib/image_import

/**
 * Theme function for the image import form.
 */
function theme_image_import_form($form) {
  $output = drupal_render($form['token_help']);
//...

From this information I gather than the contrib image field is not really performing the token replacing. All I know is that I am able to add tokens to the image upload field, without using the recommended module.

Jorrit’s picture

It seems that the Token module adds the token support for that field. Please see http://drupalcode.org/project/token.git/blob/refs/heads/7.x-1.x:/token.m... . Perhaps something like this can be added to the Video module, but I as there is already a module for this I will not give it a high priority.

Alexander Allen’s picture

Jorrit, I agree with you that since there is a solution out there this shouldn't be a priority. Thank you for the extra information.

osman’s picture

I would like you to consider adding support for thumbnail image of the video as well.

I am creating a social video site, and using tokens for Open Graph (metatag) thumbnail image URLs would be really handy.

Open Graph (metatag)

Jorrit’s picture

I think you're posting in the wrong issue. This issue is about using tokens in a Video module setting, not about exposing Video module information for other settings. You can create a new feature request if you want.

michael.k’s picture

I'd like to also request Token support for Video files and thumbnails.

There are obviously a lot of potential variations on this, which by itself is a good argument for token support.
Here is one implementation, which enables file segregation for large numbers of subjects:

For subject jugglers:
circus.example.com/videos/originals/jugglers/movie001.mov
circus.example.com/videos/thumbnails/jugglers/001-movie001.jpg
circus.example.com/videos/converted/jugglers/movie001.mp4
circus.example.com/videos/converted/jugglers/movie001.webm
circus.example.com/videos/converted/jugglers/movie001.ogv

For elephants with an alternate pattern:
circus.example.com/videos/elephants/originals/movie002.mp4
circus.example.com/videos/elephants/thumbnails/001-movie002.jpg
circus.example.com/videos/elephants/converted/movie002.mp4

For clowns yet another alternate pattern:
circus.example.com/clowns/videos/originals/movie003.mov
circus.example.com/clowns/videos/thumbnails/001-movie003.png
circus.example.com/clowns/videos/converted/movie003.webm

An alternate pattern that preserves the originals with token paths but adds [term] to the files themselves:
circus.example.com/videos/originals/trapeze/_cameraFileName00x.mov or
circus.example.com/videos/thumbnails/001-trapeze004.jpg
circus.example.com/videos/watermark/copyright.jpg
circus.example.com/videos/trapeze004.m4v

Lastly, I think it would be useful to have the option to remove the /converted and /numbered directories to simplify the path.

osman’s picture

@Jorrit, I meant to point out, exposing thumbnail URLs as tokens too would be great.
Open Graph and/or Meta tags would be one great potential usage area, which is not directly part of the Video module itself, but I provided as an example.

Jorrit’s picture

Osman: I understand your use case and it is certainly very useful, but this issue is about something different. Therefore it would be best if you opened a new feature request, so these two features can be discussed separately. They are both token-related, but not the same.

osopolar’s picture

This adds user and entity token to the current entity. The problem is that for entity add (node add) the entity (node) token is not a available. This needs a post processing.

osopolar’s picture

Status: Postponed (maintainer needs more info) » Needs review

Status: Needs review » Needs work

The last submitted patch, video-token-to-file-path-1662970-13.patch, failed testing.

osopolar’s picture

Status: Needs work » Needs review

Hmm, the simple test failed, but I guess it's not related to this patch. ... I didn't test the Zencoder Part, but I expect it works the same way ffmpeg does.

Jorrit’s picture

Status: Needs review » Needs work

The last submitted patch, video-token-to-file-path-1662970-13.patch, failed testing.

osopolar’s picture

Status: Needs work » Needs review
FileSize
4.1 KB

Patch recreated due to changes in transcoders include files.

Status: Needs review » Needs work

The last submitted patch, video-token-to-file-path-1662970-19.patch, failed testing.

Jorrit’s picture

The error is in your code. entity_load() expects an array as the second parameter, not just an ID. Also, in TranscoderAbstractionFactoryFfmpeg::extractFrames(), $job may not yet be available because FFmpeg already generates images when the form is not submitted. Also, the entity itself may not exist yet because the form hasn't been submitted so entity-related tokens will not work. You would need to move the file after the node has been saved for the first time or you would end up with duplicate files.
Also, you are duplicating a lot of code here. Maybe you can create a new utility static method in video_utility.

osopolar’s picture

FIX: Second parameter of entity_load() is now an array.

The file still needs to be moved after the node has been saved for the first time. I'm not sure where this should be done.

I guess creating a method in video_utility will save 5 lines of the duplicated code but makes it more complicate to read. I guess currently it's not necessary, is it?