If I understand correctly, Imagecache token module finds all file fields and creates imagecache style tokens for them. However, some file field types are not images, and this can cause confusion for those fields.

For example, I have the media_youtube module installed which creates a youtube file type associated with a youtube url.
After installing imagecache_token, these youtube file fields have image style tokens listed for them. Of course, they don't work.

The uri's associated with these files are youtube uri's, not images. When rendered, the call to image_style_url falters, and the output is just the query string token (e.g. "?itok=u4sSj3FE")

Imagecache tokens should probably only be generated for image file types, but I'm not sure to differentiate between all the possible file field types.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

travelertt’s picture

I'm having the same problem with my site after I enabled this module. I had to disable it because it was effecting all of my file fields. This module should only be affecting image type files in my opinion.

travelertt’s picture

Looks like the change in the commit is causing the problems. I undid the patch on my site.
https://www.drupal.org/node/2365049

travelertt’s picture

Here is a patch to remove file field type tokens.

DamienMcKenna’s picture

Status: Active » Needs work

There are many sites that use the 'file' field for adding images. Rather than disabling support for these, it'd be better to check the mimetype for file fields and only support images.

DamienMcKenna’s picture

amaisano’s picture

Just ran into this. Whenever this module is enabled, it thinks all my file fields are images. What's worse is using a token for [...:field_myfile:path] results in a default/files/styles/path, which is incorrect if it's a regular document upload.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
7.99 KB

This adds a settings page so you can control which File and Media fields will have the tokens.

deanflory’s picture

Thanks Damien, will check it out.

deanflory’s picture

DamienMcKenna, the patch in #7 either causes an error or reveals an underlying error. Sorry I'm not adept at module coding to know what is going on, but someone else had filed an error issue with Context that matched the error I was experiencing.

Any chance someone could take a look at it?:
#2532084: DB error when loading a context with menu reaction with Context v3.3 and v3.5+
https://www.drupal.org/node/2532084

I'm adding it as a related issue just in case that helps someone find the right solution eventually.

DamienMcKenna’s picture

DamienMcKenna’s picture

FileSize
5.5 KB

I caught the error - I made a mistake on the info file X-) This patch should fix it.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed 64438a5 on 7.x-1.x
    Issue #2407461 by DamienMcKenna: Add option to control which file and...

  • DamienMcKenna committed 0dd21bf on 7.x-1.x
    Issue #2407461 by DamienMcKenna: Improvements to the admin form.
    
DamienMcKenna’s picture

Component: Code » Integration with other media modules
deanflory’s picture

Thanks for the time and effort Damien!

nickcontino’s picture

I updated to this release, but its not saving the options under admin/config/media/imagecache-token

I click the fields I want, and hit save. I get the usual "The configuration options have been saved.", but then all checkboxes are unchecked, and I'm unable to use the tokens.

DamienMcKenna’s picture

Whoops! Forgot to add the #default_value to the form field. Thanks for noticing, nickcontino.

DamienMcKenna’s picture

Status: Fixed » Needs review
FileSize
366 bytes

And this patch adds hook_uninstall() to remove the variable.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed a1d7bdf on 7.x-1.x
    Issue #2407461 by DamienMcKenna: Remove the variable via hook_uninstall...
  • DamienMcKenna committed bed7700 on 7.x-1.x
    Issue #2407461 by DamienMcKenna: Admin form wasn't saving values.
    
DamienMcKenna’s picture

Status: Fixed » Needs review
FileSize
761 bytes

One more issue - always support image fields. Duh.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed 14ccec8 on 7.x-1.x
    Issue #2407461 by DamienMcKenna: Always support image fields.
    

Status: Fixed » Closed (fixed)

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