5

Token browser does not show the options for file properties. [node:file-field:0:file:url] gets the url, but is there a list of all file options? Or is there a way to check it from sourcecode somehow?

Gathering the list:

  • [node:field-image:0:file:url]
  • [node:field-image:0:file:extension]
  • [node:field-image:0:file:name]
  • [node:field-image:0:file:size]
  • [node:field-image:0:file:mime]
  • The last thing that is still unknown to me is if there is an option to pull image width and height? If I remember correctly that data is in the db.
2
  • Though I would add some context. I am using tokens in metatag module.
    – ram4nd
    Jul 19, 2016 at 11:00
  • You can create your own custom tokens like this. There is also a module for that
    – mchar
    Jul 19, 2016 at 20:44

2 Answers 2

2
+100

Using contrib module

Imagecache Token provides a list of token for image styles, which includes image width and height.

Token list provided by Imagecache Token

If you want to have those data of original image, you can create an image style original without adding any effect at admin/config/media/image-styles/edit/original

Create empty image style

Now you can retrieve the image width and height with:

  • [node:field_image:original:width]
  • [node:field_image:original:height]

New token list provided by Imagecache Token

Downside

All images will be duplicated to the original image style folder.

2
  • It would be perfect if you could get the image data without the duplicate. But I guess this is a legit option.
    – ram4nd
    Jul 22, 2016 at 10:49
  • @ram4nd Thanks, I think it would be the only way to do that without custom module. Do you feel comfortable on creating custom module? This module is the good starting point. I will look into it today later.
    – Jimmy Ko
    Jul 22, 2016 at 11:10
2

For file https://www.drupal.org/node/390482#token-file https://www.drupal.org/project/imagefield_tokens and add https://www.drupal.org/project/filefield_paths add this module for {The File (Field) Paths module extends the default functionality of Drupal's core File module, Image module and many other File upload modules, by adding the ability to use entity based tokens in destination paths and file names.}

Check this screenshot:

enter image description here

2
  • The last thing that is still unknown to me is if there is an option to pull image width and height? If I remember correctly that data is in the db.
    – ram4nd
    Jul 20, 2016 at 14:13
  • The question was not about using tokens in field settings. It was about using image field tokens in general.
    – ram4nd
    Jul 22, 2016 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.