• So here’s the deal…by default, when you insert an image into a post, the image is wrapped with just an anchor tag, right? Right. What I’m looking to do is modify that behavior so that the anchor is also wrapped inside of a div. Yes, I know I can just do it manually inside of the html editor, but I’d like it to be automatic.

    I’ve been scanning the WordPress source code trying to find the script that generates the image inside of that link, but I have yet to find it.

    Can anyone shed some light as to where I should look or what I should do? If I have to write a plugin, so be it, but I at least need a hook.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Why do you need a div?

    Thread Starter zfisic

    (@zfisic)

    Well I really just need some kind of block-level styling hook. And I’d really rather not make the anchor or the img tag “display:block”.

    Now that I think about it though, it probably isn’t smart to generate a div in that context, since the anchor and img tags already get thrown inside a ‘p’ tag automatically. And a div inside a p tag causes more problems than it solves.

    I think in the end, I’ll have to use “display:block”, but I’d still like to have a wrapper around the anchor tag. Like a span tag or something…

    I think so, too. The images added via Media Library also have many classes you could use.

    Also, once you start hacking the source code for WordPress, upgrading would be a pain.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Insert image into post with wrapping div?’ is closed to new replies.