I was based on your reply and create something like that.
function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) {
$attr = get_field('CUSTOM FIELD NAME', $id);
if ($attr !== NULL) {
$html = str_replace('<img ', '<img data-attr="'. $attr .'" ', $html);
}
return $html;
}
add_filter('image_send_to_editor', 'filter_image_send_to_editor', 10, 8);
This solve my problem. Thanks again for help 🙂
My bad luck. I don’t use WordPress’ Featured Image system. I want to put it like simple image to post content – like pressing a “add media” button and choosing right image.
I am very appreciate for help. Thanks a lot.
Thanks for reply.
Where should I put it? When I put it to function.php I see it in api… but on the top, so I’m sure I’m wrong 😉