THE ANSWER
Well as it happens many times in my life – i found the answer myself.
For people who struggles as me here the answer:
$post['errors']['field_name']['errors'][] = __('Error text here.');
if you do that – error text will be displayed at the bottom of that field. In my case this doesn’t work because i’m using inline media uploader, but with standard WP media uploader (the popup version) it’s working just fine.
BTW best article about custom fields is here: http://net.tutsplus.com/tutorials/wordpress/creating-custom-fields-for-attachments-in-wordpress/
Related Posts:
- Add validation and error handling when saving custom fields?
- Remove Dimension from wp_get_attachment_image
- explode array within shortcode
- How can I append custom data to images in the editor?
- How can I remove fields in the attachment editor?
- Saving Custom Field in Attachment Window in WordPress 3.5
- Correct Approach for Validating Custom Field Input
- Add multiple images to a page sidebar
- How to set a default meta value for custom field
- Add custom field to image editor
- How to save custom fields for attachments
- How to make custom comment fields required and message field not required
- Display info from custom fields in all images’ HTML
- How to reload the role specific registration form on validation errors?
- copy attachments to another post type and change attachment url
- ajax delete value from custom field array
- Save attachment custom fields on front end
- Insert attachment ID in custom field from media uploader
- How to validate custom field on lost password form before the user id field?
- How can I store a file in the database in the same way WordPress and ACF do?
- Getting the ID of any image for use in functions.php
- How do i save and retrieve custom attachment meta?
- Custom field not updating when value is empty
- how to upload a image from frontend with wp_insert_post and also update_post_meta?
- Link FROM attachment to full post and get custom fields values on attachment page?
- Warn user that data may be lost for custom pages
- Attach images to posts using custom fields (just paths to images already uploaded)
- How to add fields in custom registration form, validate it and aave to db? [closed]
- How to load script conditionally on custom field in wp_postmeta?
- Show custom field on attachment page?
- Save attachment ID instead of URL in custom field
- How to validation for sanitize_URL?
- Making custom meta box required (with error message if not filled in) on Gutenberg
- Shortcode for Custom Field of Media Attachment (to use with Featured Images)
- Custom field in media library not saving, selected() function not adding “selected” to select list input type
- How to delete attachments associated with custom field type when post property changes? [closed]
- How to format the various types of custom fields?
- Media Attachment Custom Meta Fields not saving in Media Uploader when using jQuery UI Autocomplete
- Validating custom meta boxes with jQuery results in posts being saved as draft instead of published post
- Adding thumbnails for non-image attachments
- How can I attach files without using a plugin?
- Set post status to draft after validating post meta values in save_post hook
- Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
- WP_Query – Order results by meta value
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- getting all values for a custom field key (cross-post)
- How to add a custom field in the advanced menu properties?
- Custom query with orderby meta_value of custom field
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Using meta query (‘meta_query’) with a search query (‘s’)
- Can I exclude a post by meta key using pre_get_posts function?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Show Custom Fields in Quick Edit
- Remove type attribute from script and style tags added by WordPress
- Where are custom field values stored in the database
- Validating Custom Meta Box Values & Required Fields
- Max length of meta_value
- Add custom fields to wp native gallery settings
- How to fix missing custom fields after upgrading to WordPress 4.8.1?
- don’t publish custom post type post if a meta data field isn’t valid
- How to enable custom fields for pages (if not a bad practice)?
- How can I add extra attribute in the ‘Page Attribute’ section in wp-admin for pages?
- Is there a way to set default custom fields when creating a post?
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Custom field/meta populated by dropdown of existing posts?
- Difference between meta keys with _ and without _ [duplicate]
- Is there any action filter/hook for validating a custom field before publishing the post?
- Orderby meta_value only returns posts that have existing meta_key
- Underscores in custom fields
- What is the index [0] for on post meta fields?
- What is “meta_input” parameter in wp_insert_post() used for?
- Query Posts or Get Posts by custom fields, possible?
- How to validate custom fields in custom post type?
- How should one implement add_settings_error on custom menu pages?
- How to enable revisions for post meta data?
- Sortable Custom Columns in User Panel (users.php)?
- Any way to add custom options to Gallery Settings?
- The “_encloseme” Meta-Key Conundrum
- ORDER BY custom field value
- Individual Widgets per Page
- Add subtitle to Woocommerce product title
- Best way to programmatically remove a category/term from a post
- Importing data for advanced custom fields plugin?
- Gutenberg add a custom metabox to default blocks
- SQL Query to copy value of a meta_key into another meta_key
- ‘Preview Changes’ for custom meta boxes?
- Adding a custom field to the site identity menu
- Using TinyMce with textareas in meta boxes on custom post types
- Validation error: Extending Gutenberg gallery block
- Filter WP_Query for posts having a certain meta-value
- How to correctly call custom field dates into a posts_where filter using SQL statements
- Using get_post_meta with new_to_publish
- Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)
- Add a Jquery Datepicker to custom field in post edit
- add meta box – custom field : which to choose?
- Preserving line breaks when saving and displaying custom fields data
- How to return Meta data from the REST API?
- Advanced Custom Fields – Get custom fields from parent page
- Can I query custom meta data through WP_Query