This type encapsulates a unlimited list of uploaded images each along with an optional number of derived images like thumbnails. Both the main image and the derived thumbnails will be run through a defined filter chain. The originally uploaded files can be kept optionally.
Similar to the downloads widget, the individual images are distinguished using md5 based hashes (not their actual filenames).
Image identifier naming conventions
The various images are distinguished using these suffixes to their identifiers:
The original image will be available with the "original" identifier prefix unless configured otherwise. The main image used for display is available as "main", which will be ensured to be web-compatible. (This distinction is important in case you upload TIFF or other non-web-compatible images. All derived images will be available under the prefixes defined in the schema configuration.
An optional "quick" thumbnail mode is available as well where you just specify the maximum frame of a thumbnail to-be-generated. The auto-generated image will then be available in the attachment identified as "thumbnail".
File type conversion and image filtering
The class uses the image filter system for the actual resizing and conversion work, you need to specify all operations including resize operations in the filtering chain declaration for the corresponding derived image.
Regarding file type conversions: The original uploaded image will always be run through an automatic type conversion as the very first step before any further processing is done. From that point, no further type conversion is done unless the user specifies another one in the filter chains for a derived type. A manual initial image conversion is not yet supported by the type.
All derived images will be computed from the initially converted, uploaded image, which should minimize the losses of the subsequent conversions. This intermediate image will not be kept an any place. The keep_original option will only save the unmodified, uploaded file.
The recreate_images call (not yet implemented) will recreate all derived images from the original image. If that image is not available, the generated main image is used instead.
Derived image naming warning
Be aware that the type holds no safety code to guard against duplicate image identifiers (e.g. defining a "main" image in the derived images list). The results of such a configuration is undefined.
In addition, you should only use lowercase alphanumeric letters to identify images, as other characters like underscores or spaces are reserved for type-internal usage.
Available configuration options:
Implementation note:
Due to the fact that Imagemagick is used for most operations, this type is currently only capable of operating based on actual files, not file handles.
todo | Implement thumbnail interface. |
---|---|
todo | Operation on file handles. |
todo | Derived-images recreation. |
package | midcom.helper.datamanager2 |
array
&$info reference to the info array of given attachmentstring
&$identifier reference to the attachments' identifierSee the usort() documentation for further details.
access | protected |
---|---|
todo | compare based on metadata->score and filename (or title ???) |
array
The first image list.array
The second image list.int
A value according to the rules from strcmp().see | \midcom_helper_datamanager2_type_blobs::_store_att_map_parameters() |
---|
Unless specified, the function creates a unique image identifier based on the hash of the current timestamp, the uploaded filename and the name of the temporary upload file.
string
The name of the image attachment to be created.string
The file to load.string
The title of the image.boolean
Indicating success.string
identifier for $this->images arraystring
the midcom_helper_imagefilter filter chain to applyboolean
indicating success/failureThen we call the base class.
In case that there is no image uploaded, an empty string is returned.
string
The identifier of the image to delete.todo | Implement |
---|
todo | Implement |
---|
string
string
Attachment mapstring
image to rotatestring
direction to rotate toboolean
indicating success/failureLoads and processes the $tmpname file on disk. The identifier is used to select the image in question.
string
The image identifier to use.string
The name of the image attachment to be created.string
The file to load.string
The title of the image.boolean
Indicating success.string
The image identifier to use.string
The name of the image attachment to be created.string
The file to load.string
The title of the image.boolean
Indicating success.It is updated accordingly on all save operations and complements the base type's _save_attachment_listing. It is stored to have a safe way of loading the images (heuristics could not be safe enough when subtypes create non-md5 based identifiers).
This is essentially a reordered version of the $attachments_info member: It is multi-dimensional, mapping the image identifier with all images available for that image. The actual images will only have the derived image name (like "thumbnail" as array key.
Example: Assume we have the images "original", "main" and "thumbnail" available for each image. While the $attachments and $attachments_info lists will just identify the images with their full handle, $attachments_info["{$md5identifier}_main"], this member will list the attachment as $images[$md5identifier]['main'] (as well as ...['original'] and ['thumbnail']).
The actual structures are references to the corresponding $_attachments_info entries.
see | \$attachments_info |
---|