Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a way to parse WP caption shortcodes #10

Open
camfindlay opened this issue Sep 13, 2015 · 2 comments
Open

Need a way to parse WP caption shortcodes #10

camfindlay opened this issue Sep 13, 2015 · 2 comments

Comments

@camfindlay
Copy link
Owner

importing from WP many images are often wrapped in a

[caption id="attachment_8393" align="alignnone" width="111" caption="Caption Text Goes Here!"]
image here
[/caption]

perhaps some way to either parse and store these as html on import OR perhaps a SS shorttag that acts in the same manner as WP captions?

@adam-stead
Copy link

If your happy to ignore the parameters on the caption (which we where) you can just use a standard shortcode parser registering a shortcode called caption (https://docs.silverstripe.org/en/3.2/developer_guides/extending/shortcodes/)

Here is the function I used.

public static function CaptionShortcode($arguments, $content = null, $parser = null, $tagName) { return "<div class='image-caption'>" . $content . "</div> "; }

with registration in _config.php of
ShortcodeParser::get('default')->register('caption', array('Page', 'CaptionShortcode'));

@camfindlay
Copy link
Owner Author

happy to accept a pull request on the WIP improved importer at #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants