• Kevin

    (@torahboy)


    I was able to add a “tag” field to my Media Library images with the following code:

    function wptp_add_tags_to_attachments() {
            register_taxonomy_for_object_type( 'post_tag', 'attachment' );
        }
        add_action( 'init' , 'wptp_add_tags_to_attachments' 

    Which I found online and it worked perfectly. This is what it looks like:
    See image attachment
    I now want to add a field to add a CSS class name to an individual image. But I can’t find nor figure out how to achieve this.
    Has anyone done this and can you point me in the right direction on how to accomplish this?
    As always… Thanks.

Viewing 1 replies (of 1 total)
  • Joy

    (@joyously)

    There is no built-in way to associate a class with an image, because that is specific to HTML and there are many places that HTML is generated to output the image. There are also a lot of places that the image is used without generating HTML (such as making smaller versions of the image).

Viewing 1 replies (of 1 total)

The topic ‘Adding custom CSS field to Media Library image’ is closed to new replies.