I have a node content type with multiple images and I would like to get the first image only. In order to get the first image I need to use - instead of _.
For example:
[node:my-image:0:image-style-name]
I tried to add the following to imagecache_token_token_info_alter() but still no luck:
$token_type = token_get_entity_mapping('entity', $entity_type);
if (!empty($data['tokens'][$token_type][$field['field_name']])) {
$data['tokens'][$token_type][$field['field_name']]['type'] = 'image-field';
}
// Also check for tokens that are using dashes.
$dash_field_name = str_replace('_', '-', $field['field_name']);
if (!empty($data['tokens'][$token_type][$field['field_name']])) {
$data['tokens'][$token_type][$field['field_name']]['type'] = 'image-field';
}
If anyone has any suggestions I can write the patch.
Comments
Comment #2
tannguyenhn commentedAlbertski
I can see module version 7.x-1.0-rc2 and dev already support do this. If you only want get first image please enter token [node:field_name_image:image_style:first] without custom anycode :D
Comment #3
tannguyenhn commented