Add custom CSS classes to Add Media uploads?
-
I’ve noticed that if you upload files and insert them into your post/page via any of the Add Media buttons none of the resulting media items or links have any custom CSS class assigned to them.
E.g. If you attach a text file and then insert the link to it into your post, you just get the following:
<a href="https://www.site.com/wp-content/uploads/somefile.txt">some file</a>
Surely it must be possible to either create a plugin or edit the core files such that when you Add Media and insert it into the post it would post the link with an added CSS class attribute based on the type of media being inserted so that you could then style those uploaded file types. E.g.
<a class="added_misc" href="https://www.site.com/wp-content/uploads/somefile.txt">some file</a> <a class="added_img" href="https://www.site.com/wp-content/uploads/somefile.txt"><img src="img.jpg"></a>
Why? Among other things, I want to be able to automatically have CSS for two different types of links within a post — a regular web link and a separately styled file download link generated by the Add Media window.
If anyone knows how to do this or has an idea of how it can be done, can you point me in the right direction?
- The topic ‘Add custom CSS classes to Add Media uploads?’ is closed to new replies.