If a user had a caption in their blog entries, wordpress's caption code is printed on the page and is not addressed on import.

See screenshot.

CommentFileSizeAuthor
Screen shot 2009-11-28 at 9.20.40 AM.png137.58 KBkmonty

Comments

lavamind’s picture

Priority: Critical » Normal

Looks to me like we would have to imitate the way Wordpress itself handles those captions and modify the body. But since this process probably depends on some user-defined settings, I'm not sure that would be the best way...

lavamind’s picture

Furthermore, this and the video tags, should be things translated at the moment of exporting, by Wordpress, not when importing...

kmonty’s picture

I started a new project to help with this: http://drupal.org/project/caption_filter

I'll write some script to handle converting the existing code to this method.

kmonty’s picture

Assigned: Unassigned » kmonty
lavamind’s picture

Let me know when the module has a public release so I can document it.

kmonty’s picture

I actually found some bugs in it that I won't have time to fix until after the holiday, so I didn't commit to CVS. I'll let you know as soon as I get it committed.

kmonty’s picture

Just to update, I released a version of Caption Filter but it isn't in the same format of Wordpress.

Wanted to relate this to #739798: Using Caption Filter to migrate captions from Wordpress

Not sure what queue this thread belongs in.

Melissamcewen’s picture

Assigned: kmonty » Unassigned

Kmonty's filter is nice to duplicate the functionality of captions in Wordpress, but it would be much nicer to just get rid of the [caption] altogether upon import.

lavamind’s picture

@Melissa M: Getting rid of [caption] would indeed be great but the problem is determining the appropriate markup to generate. If you have any ideas on this, please share.

Melissamcewen’s picture

I love Kmonty's module, which turns it into a div with a class that's "caption" so I can style it as such. It's really too bad it doesn't work with the markup on the wordpress sites I've had to import which is [caption ="blahblahblah"] rather than [caption=blablahblah]

kmonty’s picture

Wordpress's caption code is not simple and therefore far to difficult to use. Someone just needs to write some migration regular expressions and it is done.

lavamind’s picture

In the Wordpress [caption] tag, what attributes to we need to migrate? Only "align" and "caption" ?

grasmash’s picture

I wanted to get rid of all of the caption tags without getting rid of their contents, so I did this:

ran a find and replace with this regex (replacing with empty string) to remove all "[caption with-anything-here]":

\[caption([^\]])*\]

then ran a literal find and replace to get rid of all "[/caption]"

you could also run a find and replace with this regex to get rid of all caption tags, including their contents:

\[caption.*\[\/caption\]

mattiasj’s picture

It would be great to have the option before importing to totally strip all [captions], it would be great in some cases!