Question

So, I'm trying to migrate a database from Textpattern CMS to something more generic. There are some textpattern-specific commands inside of articles that pull in images. I want to turn these into generic HTML image links. At the moment, they look like this in the sql file:

<txp:upm_image image_id="4" form="dose" />

I want to turn these into something more like this:

<img src="4.jpg" class="dose" />

I've had some luck with TextWrangler doing some regex stuff, but I'm stumped. Any ideas on how to find & replace all of these image paths?

EDIT: For future reference, here's what I ended up doing in PHP to output it:

$body = $post['Body_html'];
$pattern = '/txp:upm_image image_id="([0-9]+)" form="([^"]*)"/i';
$replacement = 'img src="/images/$1.jpg" class="$2"';
$body = preg_replace($pattern, $replacement, $body);
// outputed <img src="/images/59.jpg" class="dose" />

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top