Different ID on "Set featured image" link if there is already an image set
|Reported by:||ryanimel||Owned by:|
I ran into a situation where I wanted to target the "Set featured image" link text in the featured image metabox. The "Set featured image" link displays and has an id of "set-post-thumbnail". When you set the thumbnail, the link still has an ID of "set-post-thumbnail" though now it is wrapping around the thumbnail image rather than the "Set featured image" text. Then a second link is added to remove the featured image with the id of "remove-post-thumbnail".
In my situation I wanted to target the "Set featured image" link (with the text) and the "Remove featured image" link separately, but this was tricker than it needed to be because the "Set featured link" keeps the same id of set-post-thumbnail when it is wrapped around the thumbnail image.
Beyond my specific issue, I think it could be argued that this link deserves a specific id, since the action the link is performing is modifying the featured image more than it is setting it.
So I've included a patch here that will modify the $set_thumbnail_link variable when the $thumbnail_id is present and change the link's id to modify-post-thumbnail. I'm not sure if it's the most elegant/clever way to achieve what I'm after, but I know it gets the job done.