Adds an image custom field for textpattern
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.textile
jcr_image_custom.php
jcr_image_custom_v0.1.1.txt

README.textile

jcr_image_custom

Adds a single extra custom field of up to 255 characters to the Content › Images panel and provides a corresponding tag to output the custom field.

Use cases

Use whenever extra information needs to be stored with an image. For example:

  • Store a youtube/vimeo link or video-ID with an image for generating custom video poster images.
  • Store the download url of a corresponding hi-res press image not stored in txp.

Installation

Paste the code into the Admin › Plugins panel, install and enable the plugin.

Tags

<txp:jcr_image_custom />

Outputs the content of the image custom field.

Tag attributes

escape
Escape HTML entities such as <, > and & prior to echoing the field contents.
Example: Use escape="" to suppress conversion. Default: html.

Example

Produce a gallery of custom video poster-images (from images assigned to the image category “videos”) that open a corresponding youtube video (defined in the image custom field) in a lightbox modal:

<txp:images wraptag="ul" break="li" category="videos" class="video-gallery">
  <a href="//www.youtube.com/watch?v=<txp:jcr_image_custom />" title="<txp:image_info type="caption" />" data-lity>
    <txp:thumbnail />
  </a>
</txp:images>

where the image custom field is used to store the Video ID of the YouTube video. This example uses the lity lightbox script.

Changing the label of the custom field

The name of custom field can be changed by specifying a new label using the Install from Textpack field in the Admin › Languages panel. Enter your own information in the following pattern and click Upload:

#@admin
#@language en-gb
jcr_image_custom => Your label

replacing en-gb with your own language and Your label with your own desired label.

De-installation

The plugin cleans up after itself: deinstalling the plugin removes the extra column from the database. To stop using the plugin but keep the database tables, just disable (deactivate) the plugin but don’t delete it.

Changelog

Version 0.1.1 – 2016/12/05

  • Remedy table not being created on install

Version 0.1 – 2016/04/16

  • First release

Credits

Robert Wetzlmayr’s wet_profile plugin for the starting point, and further examples by Stef Dawson and Jukka Svahn.