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.

Comments

vaartio created an issue. See original summary.

vaartio’s picture

Status: Active » Needs review
StatusFileSize
new1.51 KB

Here's a patch.

jstoller’s picture

Status: Needs review » Reviewed & tested by the community

The 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.

damienmckenna’s picture

I 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.

damienmckenna’s picture

Title: Rename mimetype attribute as filemime » Confirm 'mimetype' token works as intended
Issue tags: +Needs tests
Related issues: +#2578977: Improve the labels of each attribute

Lets 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.

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs work
sgdev’s picture

As 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 $property value. See this issue: https://www.drupal.org/project/imagecache_token/issues/2956389

chris matthews’s picture

@ron_s, where do you think this issue stands?

I have a patch that handles both of them

(for #2956474: No support for File Entity mimetype and file size)

However, there is a larger issue here where this module does not work correctly with File Entity due to image style not being a $property value. See this issue: #2956389: Does not work with File Entity fields, even though module has option to enable them

See also #2947445: Undefined index: {file_style} in _file_entity_tokens_get_property() )

damienmckenna’s picture

The patch also needs to be rerolled after #3033559 was committed.

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.16 KB

Reroll after #3033559: Move token hook implementations to a tokens.inc file was committed. #5 still needs to be addressed (issue needs automated tests).

Status: Needs review » Needs work

The last submitted patch, 10: 2582497-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

sgdev’s picture

Due to recent updates in the File Entity module, I can confirm my issues in #7 are no longer a problem. The use of mimetype and filesize tokens 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