Validating Image Blocks and Meta Information
11 min
purple hub summary this article describes how to use the image block and meta information validation feature within purple hub the feature ensures that custom fields (such as copyright ownership) are filled in and that images are included in the block this guide will walk you through the requirements, setup and a detailed description of the feature in action at the moment, only custom fields (acfs) and information about whether an image is included in the image blocks can be validated validation of standard fields such as alt tags, title tags, captions etc isn't possible at the time of writing upload time vs publish time validation the validation described in this article runs in the article editor and blocks publishing — not uploading an image that is missing a required field can still be uploaded and stored in the media library; it is only flagged once the image is used in an article to require a field before an image can enter the library at all, mark the acf field itself as required on its validation tab (see create custom fields in purple hub # ) a required acf field on media keeps the upload dialog's save button disabled until the field is filled, so it applies to every matching asset — whether or not the image is ever used as a rule of thumb, use the acf required setting to guarantee metadata on every asset in the library, and image block validation to guarantee it only on images that are actually published enabling both applies the check twice — at upload and again at publishing — so choose the one that matches your goal preconditions have an admin role in purple hub have a field group and a custom field defined that applies to images see create custom fields in purple hub docid\ sfolj8v8qcn3m3jibzbuk have the name of your custom field by hand (e g , 'imagecredits' or 'medialibrarycopyrightowner') that need validation or have the purple dam plugin active with exif and/or iptc data enbaled description ticket https //purplepublish atlassian net/browse/backend 5397 https //purplepublish atlassian net/browse/backend 5397 configuration settings image block validation is now split across two places on the purple blocks settings page (per block) image requirement — the block must contain an image meta fields as image caption — which metadata fields are shown as the caption beneath the image in the editor (see below) on settings → media → general → required image fields (central, all in post images) images in the post content → required metadata — the metadata fields that must be filled on every image in the post body before publishing this single list now covers the image block, gallery block, and carousel block alike — you no longer configure required metadata per block selectable fields include title, alt text, caption, description, and any attachment acf / exif / iptc field (for exif/iptc use the internal name, e g mlo exif grouped author ) enabling validation on image blocks using purple blocks navigate to the image block in purple hub, go to the section where purple blocks (image blocks) are managed you can set a block as "required" for a post, meaning that the post will not be published unless the block contains valid content new validation options there are now two additional validation options for image blocks image requirement the block must contain an image custom field validation custom fields (such as metadata) must be filled in for each image testing the validation create a new article and add an image block using purple blocks select an image from the media library that does not have the required custom field (e g , "media library copyright owner") set a warning will appear stating that the image is missing the required field, and the article cannot be published until the field is filled in resolving validation issues to resolve the issue, either choose an image that already has the required metadata or manually set the missing field for the selected image once the field is set correctly, the warning will disappear, and the article can be published validating the presence of an image you can also configure the image block to require that an image must be selected if an image block is added without an image, a validation error will appear, preventing publication of the article until an image is selected publishing with validated images once all validations (image selection and custom field requirements) are satisfied, the article can be published without any errors enabling validation for featured images the same kind of validations can be defined separately for the featured image of an article see validating the featured image docid\ glpdx1mguplnnl wdgigt example of validation in action if an image is selected that does not have the required "media library copyright owner" field, a message will appear stating, "the selected image does not contain the media library copyright owner field " if no image is selected for an image block, another warning will appear indicating that the article cannot be published without a valid image the configured fields also show up in the block editor sidebar, where a link is provided to open them directly in the media library, where the fields can then be edited image caption preview using purple blocks similar to required fields, it is also possible to configure fields that are supposed to show up underneath an image to generate an image preview here's how to configure it open the validation settings for the image block in purple blocks and activate the "meta fields as image caption" setting enter here the image meta fields that should show up as image caption in the editor underneath the image save the settings if you now open an article containing images, the configured fields are shown as caption on the right underneath images