Token mimetype doesn't return what is expected because there's a check isset($field[$attribute]) and a field doesn't have a property called mimetype, it's filemime. Change token name to filemime and it works.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 2582497-10.patch | 1.16 KB | idebr |
Comments
Comment #2
vaartio commentedHere's a patch.
Comment #3
jstollerThe patch worked for me.
Note, if you have trouble applying the patch you may need to get the module straight from the git repo. See #2664014: Downloaded dev version doesn't include last commit.
Comment #4
damienmckennaI used 'mimetype' because it's in relation to the styled image, which has a 'mime_type' value as generated by the image_get_info() function, rather than the 'filemime' attribute of a {file_managed} object.. I need to examine this more.
Comment #5
damienmckennaLets work on some tests to confirm that the 'mimetype' token works as intended. FYI there's also #2578977: Improve the labels of each attribute to improve the UX.
Comment #6
damienmckennaComment #7
sgdev commentedAs mentioned here (https://www.drupal.org/project/imagecache_token/issues/2956474), both mimetype and file size do not work, because they are not proper FIle Entity keys.
I have a patch that handles both of them... I don't think patch in #2 is the right way to do it, because you'll run into issues with standard image fields using that approach.
However, there is a larger issue here where this module does not work correctly with File Entity due to image style not being a
$propertyvalue. See this issue: https://www.drupal.org/project/imagecache_token/issues/2956389Comment #8
chris matthews commented@ron_s, where do you think this issue stands?
(for #2956474: No support for File Entity mimetype and file size)
See also #2947445: Undefined index: {file_style} in _file_entity_tokens_get_property() )
Comment #9
damienmckennaThe patch also needs to be rerolled after #3033559 was committed.
Comment #10
idebr commentedReroll after #3033559: Move token hook implementations to a tokens.inc file was committed. #5 still needs to be addressed (issue needs automated tests).
Comment #12
sgdev commentedDue to recent updates in the File Entity module, I can confirm my issues in #7 are no longer a problem. The use of
mimetypeandfilesizetokens work as expected with the File Entity module. The patches on this thread were not necessary.However, I did identify that alt/title fields do not work correctly with File Entity, and have created a patch for review: https://www.drupal.org/project/imagecache_token/issues/3158117