Within imagecache actions, I am using text ??. Right now use the tokens of the fields to display certain information on the pictures. I am searching which routine to call to translate the token to text, so I can manipulate the text with PHP functions. Specifically, tokens that address taxonomy terms. I prefer not to directly go to addressing and calculating arrays as that gets quite messy in the user interface of imagecache.. Anybody knows how/ can help me?

Thanks!

Comments

dman’s picture

If you have a node object that you need to pull some arbitrary data out of, you'll have to use the data array that it gives you.
The structure of the way a $node presents its taxonomy terms can be seen if you enable the devel.module.

I imagine you want something like

$terms = array();
foreach ($node->taxonomy as $term) {
  $terms[] = $term->name;
}
return join(', ', $terms);

We don't have token support, though it may be possible one day

fietserwin’s picture

Component: Text Actions Module » Custom Actions Module
Status: Active » Closed (won't fix)

The 6.x-2.x is not supported anymore and we are closing all issues for it.

If programming a PHP snippet for either a text effect or a custom action, I don't see why you would need token support. You have the data available, or at least have a starting point to fetch the required and related data. And subsequently it is just extracting that data. On the other hand, if token support allows to outsource the hard work of getting related data, than that could be very easy and very powerful. Still, I would think that there already must be some kind of token API that already offers this in a programmatic way, thus readily available in your snippets.

Please feel free to reopen against the 7.x-1.x branch if you want the feature implemented over there.

dman’s picture

Status: Closed (won't fix) » Postponed

Token support for textactions is a natural fit, I think.
It would ease up a LOT of the currently very fiddly ways of getting at $node data, and system strings as well for that matter.
It would make most text actions possible without exposing PHP code format (!)
And be self-documenting somewhat. Much better than the current situation.

Basically, the textarea where we can add text is either plaintext or php-evaluated.
It should be easy to process tokens found within the plaintext, seeded with token replacements generated from the $node object where possible.
I'd keep this on the TODO list as it's a good goal.

dman’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev

D7

dman’s picture

Title: Addressing txonomy through tokens-function in text action through PHP » Support tokens in text actions for images

title

fietserwin’s picture

Component: Custom Actions Module » Text Effects Module

I see, I was thinking of token suppor tin the PHP case, but for the "plain text" case this would indeed be great. That would make the current special cases (image alt and title) redundant. Moving to text module.

derhasi’s picture

Status: Postponed » Needs review
Issue tags: +token integration
StatusFileSize
new4.44 KB

I managed to implement token replacement. I built it to use file_entity fields, but it should work fine without file_entity enabled.

The patch is attached

ryan.ryan’s picture

Status: Needs review » Reviewed & tested by the community

Yo, this patch applied cleanly and enabled token support for me. Not throwing any errors either. Seems RTBC.

fietserwin’s picture

Category: support » feature
Status: Reviewed & tested by the community » Needs review
Issue tags: -token integration
StatusFileSize
new9.61 KB

I made some changes to the latest patch here:

  • Rerolled against current dev.
  • Removed function _image_effects_text_get_file_object() and used the already existing imagecache_actions_get_image_context() instead.
  • This also gives us tokens from referring entities.
  • Updated token help to display all token types, also nodes and other entity types.
  • The patch also contains some formatting and typo corrections.

Before committing this, I want to get some advice on:

  • I'm not so sure about the default value for this one.
  • Why not integrate token support in the static text field? If so, can someone give a good description to use as help text?
  • Why not discontinue the alt and title support as this can now be done with tokens? Although you will nee to install entity_token module and patch that module for issue #2013473: Title attribute of image field not listed as possible token.
arx-e’s picture

i have applied the patch in #9 (1152736-9.patch) to the latest dev version and I am using the text effect to watermark photos with the photographers name from a term reference field of the same node.
It works like a charm in my first tests!
A great feature for the site I am building and big thank you to the above contributors!

Should definitely be part of the module.

fietserwin’s picture

Status: Needs review » Fixed

Committed a final version that differs from #9 in the fact that the "static text" and "token" options are merged into 1 option.

Status: Fixed » Closed (fixed)

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