Closed (fixed)
Project:
ImageCache Actions
Version:
7.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 May 2012 at 09:19 UTC
Updated:
6 Jun 2012 at 09:01 UTC
I would like to use a cck field - length as a variable to create an image size using custom action, image_scale().
Is there a way to access a cck field and use it in the php custom action code? I tried the code in http://drupal.org/node/1402790 but I just get errors.
Comments
Comment #1
fietserwinPlease see the readme.txt of the custom actions sub module. The code in the mentioned issue is indeed outdated.
This does need some documentation, but I am not sure how and where. W\ill follow up on that.
Comment #2
fietserwinComment #3
LTech commentedI don't have a readme file in /sites/all/modules/imagecache_actions/customaction.
There is only one readme file for imagechache_actions and it doesn't have any info on custom action.
Where can I find it?
Comment #4
fietserwinThere is a sites/all/modules/imagecache_actions/customactions/README.txt. I checked both the 7.x-1.0 download and the current dev. And it is even available via the module list admin page.
Closing this issue: documentation will be a separate task and we are not going to keep separate doc issues open. For the moment the README.txt suffices.
Part of the contents:
To ease your task, this effect makes some information regarding the image being
processed available in 2 variables: $image and $image_context. These variables
are readily available in your snippet.
$image is an associative array containing:
- source: string, the source of the image, e.g. public://photo.jpg
- info: array, example data:
- width (int) 180
- height (int) 180
- extension (string) png
- mime_type (string) image/png
- file_size (int) 4417
- toolkit: string, imagemagick or GD
$image_context is an associative array containing:
- effect_data: array, the data of this image effect, example data for the custom
action effect:
- php (string)
- managed_file: object|null. A managed file object containing these properties:
- fid (string) 2
- uid (string) 1
- filename (string) photo.jpg
- uri (string) public://photo.jpg
- filemime (string) image/jpeg
- filesize (string) 445751
- status (string) 1
- timestamp (string) 1327525851
- metatags Array [0]
- rdf_mapping Array [0]
- referring_entities: array|null. A nested array with (fully loaded) entities
referring to the current image. The 1st level of entries is keyed by the field
name, the 2nd by entity type, and the 3rd by entity id. Example data:
- field_photo Array [1]
- node Array [1]
- 12 Object of: stdClass
- nid (string) 12
- vid (string) 12
- type (string) page
- author ...
- timestamp ...
- ...
- entity: object|null, the 1st entity in referring_entities. This is for easy
access to the referring entity if it may be assumed that only 1 entity is
referring to the current image.
- image_field: array|null, the 1st image field in entity that is referring to
the current image. This is for easy access to the image field data if it may
be assumed that only 1 image field is referring to the current image. Example
data:
- fid (int) 2
- alt (string) ...
- title (string) ...
- ...
Of course there are many other possible useful globals. Think of:
- base_url
- base_path
- base_root
- is_https
- user
- language
and of course $_SERVER and $_GET.
Using these information you can access entity data as follows:
Specific case (1 entity, of known entity_type, referring to the image):
Or the more general case (not knowing the referring type, or multiple entities
that may be referring to the image):
Comment #5
fietserwinShould go via fixed...