Trying to replace this jquery code with some php server side magic:
$(document).ready(function() {
$('#text img').each(function(){
source = $(this).attr('src');
$(this).wrap($('<div class="caption '+ $(this).attr('class') + '"></div>')).removeAttr('class').removeAttr('height').removeAttr('width');
$(this).after('<p>' + $(this).attr('alt') + '</p>');
$(this).attr('src', '/system/tools/phpthumb/phpThumb.php?src=' + source + '&wl=200&hp=200&q=85&f=jpg');
});
});
All it does is take this:
<img class="right" src="blah.jpg" alt="My caption" width="100" height="200" />
And replaces it with:
<div class="caption right">
<img src="/system/tools/phpthumb/phpThumb.php?src=blah.jpg&wl=200&hp=200&q=85&f=jpg" alt="My caption" />
<p>My caption</p>
</div>
The images are scattered throughout a block of textile formated html between <p>
's. Something like this:
<p>My paragraph text</p>
<img src="image.jpg" />
<p>Another paragraph text <img src="another_image.jpg" /> with more text</p>
<p>And so on</p>
It enables users to float images left, right or center and thumbnails are automatically created using phpthumb. I'm assuming I'd need to use regular expressions. I'm new to php and only know frontend coding. How would you attack this?