Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#22 | video-token-to-file-path-1662970-22.patch | 9.45 KB | osopolar |
#19 | video-token-to-file-path-1662970-19.patch | 4.1 KB | osopolar |
#13 | video-token-to-file-path-1662970-13.patch | 4.1 KB | osopolar |
Comments
Comment #1
Jorrit CreditAttribution: Jorrit commentedHave 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.
Comment #2
Alexander Allen CreditAttribution: Alexander Allen commentedI 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!
Comment #3
Alexander Allen CreditAttribution: Alexander Allen commentedAlso 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
Comment #4
Jorrit CreditAttribution: Jorrit commentedI am not sure about the token support of the image module. What image contrib module are you referring to?
Comment #5
Alexander Allen CreditAttribution: Alexander Allen commentedThis 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
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.
Comment #6
Jorrit CreditAttribution: Jorrit commentedIt 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.
Comment #7
Alexander Allen CreditAttribution: Alexander Allen commentedJorrit, I agree with you that since there is a solution out there this shouldn't be a priority. Thank you for the extra information.
Comment #8
osmanI 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.
Comment #9
Jorrit CreditAttribution: Jorrit commentedI 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.
Comment #10
michael.k CreditAttribution: michael.k commentedI'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.
Comment #11
osman@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.
Comment #12
Jorrit CreditAttribution: Jorrit commentedOsman: 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.
Comment #13
osopolarThis 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.
Comment #14
osopolarComment #16
osopolarHmm, 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.
Comment #17
Jorrit CreditAttribution: Jorrit commented#13: video-token-to-file-path-1662970-13.patch queued for re-testing.
Comment #19
osopolarPatch recreated due to changes in transcoders include files.
Comment #21
Jorrit CreditAttribution: Jorrit commentedThe error is in your code.
entity_load()
expects an array as the second parameter, not just an ID. Also, inTranscoderAbstractionFactoryFfmpeg::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
.Comment #22
osopolarFIX: 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?