As far as I can tell you can't use :before or :after with text content on an image element? Is this correct? Am I missing something?
I know semantically this isn't correct, I'm using because I'm appending the src to the image using js, but if there's no src I'd like to display alternative content (I could use another div, but it would be nice to just use :after or :before)
This is correct. You are not able to use pseudo elements on images
As lnrbob says, you cannot use pseudo elements on images. However, put a class on the image and use a background image and you'll be accomplishing the same thing.
来源:https://stackoverflow.com/questions/11846931/pseudo-element-before-or-after-on-an-image-element