|
| 1 | +# jcr_image_custom |
| 2 | + |
| 3 | +Adds up to five extra custom fields of up to 255 characters to the |
| 4 | +[Content › |
| 5 | +Images](http://docs.textpattern.io/administration/images-panel) panel |
| 6 | +along with corresponding tags to output the custom field and to test if |
| 7 | +it contains a value or matches a specific value. |
| 8 | + |
| 9 | +### Use cases |
| 10 | + |
| 11 | +Use whenever extra information needs to be stored with an image. For |
| 12 | +example: |
| 13 | + |
| 14 | +- Store a youtube/vimeo link or video-ID with an image for generating |
| 15 | + custom video poster images. |
| 16 | +- Store the download url of a corresponding hi-res press image not |
| 17 | + stored in txp. |
| 18 | +- Store the year a picture / photograph was taken |
| 19 | +- Store the copyright owners name + link |
| 20 | +- ... |
| 21 | + |
| 22 | +## Installation / Deinstallation / Upgrading |
| 23 | + |
| 24 | +### Installation |
| 25 | + |
| 26 | +Paste the `.txt` installer code into the *Admin › Plugins* panel, or |
| 27 | +upload the plugin's `.php` file via the *Upload plugin* button, then |
| 28 | +install and enable the plugin. |
| 29 | + |
| 30 | +### Upgrading |
| 31 | + |
| 32 | +The plugin automatically migrates custom field data and the database |
| 33 | +structure from the earlier single custom field variant (v0.1) to the new |
| 34 | +format. No changes are needed to the public tags as the new default |
| 35 | +settings correspond to the old tag. Nevertheless, it is always advisable |
| 36 | +to make a database backup before upgrading. |
| 37 | + |
| 38 | +### De-installation |
| 39 | + |
| 40 | +The plugin cleans up after itself: deinstalling (deleting) the plugin |
| 41 | +removes the extra columns from the database as well as custom field |
| 42 | +names and labels. To stop using the plugin but keep the custom field |
| 43 | +data in the database, just disable (deactivate) the plugin but don't |
| 44 | +delete it. |
| 45 | + |
| 46 | +## Plugin tags |
| 47 | + |
| 48 | +### jcr_image_custom |
| 49 | + |
| 50 | +Outputs the content of the image custom field. |
| 51 | + |
| 52 | +#### Tag attributes |
| 53 | + |
| 54 | +`name`\ |
| 55 | +Specifies the name of the image custom field.\ |
| 56 | +Example: Use `name="copyright_author"` to output the copyright_author |
| 57 | +custom field. Default: jcr_image_custom_1. |
| 58 | + |
| 59 | +`escape`\ |
| 60 | +Escape HTML entities such as `<`, `>` and `&` prior to echoing the field |
| 61 | +contents.\ |
| 62 | +Supports extended escape values in txp 4.8\ |
| 63 | +Example: Use `escape="textile"` to convert textile in the value. |
| 64 | +Default: none. |
| 65 | + |
| 66 | +`default`\ |
| 67 | +Specifies the default output if the custom field is empty\ |
| 68 | +Example: Use `default="Org Name"` to output "Org Name", e.g. for when no |
| 69 | +copyright_author explicitly given. Default: empty. |
| 70 | + |
| 71 | +`wraptag`\ |
| 72 | +Wrap the custom field contents in an HTML tag\ |
| 73 | +Example: Use `wraptag="h2"` to output `<h2>Custom field value</h2>`. |
| 74 | +Default: empty. |
| 75 | + |
| 76 | +`class`\ |
| 77 | +Specifies a class to be added to the `wraptag` attribute\ |
| 78 | +Example: Use `wraptag="p" class="copyright"` to output |
| 79 | +`<p class="copyright">Custom field value</p>`. Default: empty |
| 80 | + |
| 81 | +### jcr_if_image_custom |
| 82 | + |
| 83 | +Tests for existence of an image custom field, or whether one or several |
| 84 | +matches a value or pattern. |
| 85 | + |
| 86 | +#### Tag attributes |
| 87 | + |
| 88 | +`name`\ |
| 89 | +Specifies the name of the image custom field.\ |
| 90 | +Example: Use `name="copyright_author"` to output the copyright_author |
| 91 | +custom field. Default: jcr_image_custom_1. |
| 92 | + |
| 93 | +`value`\ |
| 94 | +Value to test against (optional).\ |
| 95 | +If not specified, the tag tests for the existence of any value in the |
| 96 | +specified image custom field.\ |
| 97 | +Example: Use `value="english"` to output only those images whose |
| 98 | +"language" image custom field is english. Default: none. |
| 99 | + |
| 100 | +`match`\ |
| 101 | +Match testing: exact, any, all, pattern. See the docs for |
| 102 | +"if_custom_field":https://docs.textpattern.com/tags/if_custom_field.\ |
| 103 | +Default: exact. |
| 104 | + |
| 105 | +`separator`\ |
| 106 | +Item separator for match="any" or "all". Otherwise ignored.\ |
| 107 | +Default: empty. |
| 108 | + |
| 109 | +## Examples |
| 110 | + |
| 111 | +### Example 1 |
| 112 | + |
| 113 | +Output a gallery of custom video poster-images (from images assigned to |
| 114 | +the image category "videos") that open a corresponding youtube video |
| 115 | +(defined in the image custom field) in a lightbox modal: |
| 116 | + |
| 117 | + <txp:images wraptag="ul" break="li" category="videos" class="video-gallery"> |
| 118 | + <a href="//www.youtube.com/watch?v=<txp:jcr_image_custom name="youtube_id" />" title="<txp:image_info type="caption" />" data-lity> |
| 119 | + <txp:thumbnail /> |
| 120 | + <txp:jcr_image_custom name="youtube_author" wraptag="p" class="author" /> |
| 121 | + </a> |
| 122 | + </txp:images> |
| 123 | + |
| 124 | +where the image custom field is used to store the Video ID of the |
| 125 | +YouTube video. This example uses the [lity](http://sorgalla.com/lity/) |
| 126 | +lightbox script. |
| 127 | + |
| 128 | +### Example 2 |
| 129 | + |
| 130 | +Outputs the copyright author with or without link: |
| 131 | + |
| 132 | + <txp:images wraptag="ul" break="li" class="photoset"> |
| 133 | + <figure class="photo"> |
| 134 | + <txp:image /> |
| 135 | + <figcaption> |
| 136 | + <txp:image_info type="caption" wraptag="p" /> |
| 137 | + <txp:jcr_if_image_custom name="copyright_link"> |
| 138 | + <a href="<txp:jcr_image_custom name="copyright_link" />" class="img-owner"><txp:jcr_image_custom name="copyright_author" /></a> |
| 139 | + <txp:else /> |
| 140 | + <txp:jcr_image_custom name="copyright_author" wraptag="span" class="img-owner" /> |
| 141 | + </txp:jcr_if_image_custom> |
| 142 | + </figcaption> |
| 143 | + </figure> |
| 144 | + </txp:images> |
| 145 | + |
| 146 | +## Custom field labels |
| 147 | + |
| 148 | +The label displayed alongside the custom field in the edit image panel |
| 149 | +can be changed by specifying a new label using the *Install from |
| 150 | +Textpack* field in the [Admin › |
| 151 | +Languages](http://docs.textpattern.io/administration/languages-panel.html) |
| 152 | +panel. Enter your own information in the following pattern and click |
| 153 | +**Upload**: |
| 154 | + |
| 155 | + #@owner jcr_image_custom |
| 156 | + #@language en, en-gb, en-us |
| 157 | + #@image |
| 158 | + jcr_image_custom_1 => Your label |
| 159 | + jcr_image_custom_2 => Your other label |
| 160 | + |
| 161 | +replacing `en` with your own language and `Your label` with your own |
| 162 | +desired label. |
| 163 | + |
| 164 | +## Changelog and credits |
| 165 | + |
| 166 | +### Changelog |
| 167 | + |
| 168 | +- Version 0.2.0 -- 2020/12/17 -- Expand to handle multiple custom |
| 169 | + fields |
| 170 | +- Version 0.1.1 -- 2016/12/05 -- Remedy table not being created on |
| 171 | + install |
| 172 | +- Version 0.1 -- 2016/04/16 |
| 173 | + |
| 174 | +### Credits |
| 175 | + |
| 176 | +Robert Wetzlmayr's |
| 177 | +[wet_profile](https://github.com/rwetzlmayr/wet_profile) plugin for the |
| 178 | +starting point, and further examples by [Stef |
| 179 | +Dawson](http://www.stefdawson.com) and [Jukka |
| 180 | +Svahn](https://github.com/gocom). |
0 commit comments