Similar to below:
how to save image custom attribute in magento 2
Have followed above question and added a custom text area attribute. So far the field shows for me under "Alt Text" and then verified values saving in DB for media gallery table with below:
select * from catalog_product_entity_media_gallery WHERE value_id = 17571;
Above query returns my custom attribute and the value fine however once saved the admin product detail form does not show a value for that attribute.
My template for the new media form has a field added which looks like below:
<div class="admin__field field-image-custom_link"> <label class="admin__field-label" for="custom_image_link-save"> <span><?= $block->escapeHtml(__('Custom Image Link')) ?></span> </label> <div class="admin__field-control"> <div class="admin__field admin__field-option"> <textarea type="text" rows="2" data-form-part="<?php /* @escapeNotVerified */ echo $formName ?>" data-role="custom_image_link-save" class="admin__control-text" name="<?= $block->escapeHtmlAttr($elementName) ?>[<%- data.file_id %>][custom_image_link]"/><%- data.custom_image_link %></textarea> </div> </div> </div>
This is a modified version of template in the other question where
custom_image_link is my custom text attribute. Therefore I used
<%- data.custom_image_link %> to hopefully pull the field into form however nothing shows.
In the question it shows a
data.useforvm value however the attribute was
useforvm is not referenced anywhere else so feel there may be a step missing?