To improve user experience, I want to make changes to the image meta fields in the Media Library:
As demonstrated above, I want to change the Caption
field to Source
and remove the Alt Text
and Description
field.
How can I achieve this?
To improve user experience, I want to make changes to the image meta fields in the Media Library:
As demonstrated above, I want to change the Caption
field to Source
and remove the Alt Text
and Description
field.
How can I achieve this?
Comments are closed.
I don’t know if this answer will be of much use given the age of this question now, but perhaps it will provide an answer sufficient that you can at least consider the question answered.
I would point out this approach involves creating copies of WordPress functions, modifying them and repointing WP hooks (unhooking and rehooking), so it might be susceptible to breaking if core functionality around these functions and hooks changes such that the copied code is no longer inline with what’s in core.
The complete code exceeds the answer character limit, so here’s the class without the two copied/modified functions from wp core (see pastebin at the end for complete code).
Core WP functions:
https://developer.wordpress.org/reference/functions/edit_form_image_editor/
https://developer.wordpress.org/reference/functions/wp_print_media_templates/
Pastebin with modified functions:
https://pastebin.com/p4KH3g6v
Image fields should look something like.
And all i’ve done with these two functions is copy them straight form core, scan down the files and rename or comment out(you can straight up delete those sections of code if desired) the appropriate fields to match what you asked for. If i missed a detail or accidently commented something out that shouldn’t have been, it should be trivial to tweak.
I found this great tutorial for adding/filtering fields. However, do you think it is ideal remove core functionality? I suggest hiding the fields with css that you do not want displayed, and creating a field for
Source
rather than modifying it. The reason for this is so that other devs or plugins can utilize the core functionality with your plugin or theme without a lot of workaround.