Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
07-01-2009, 09:51 PM #1
- Join Date
- Jul 2009
- Thanked 0 Times in 0 Posts
Preg_Replace To Show Only Alt-Tags
I am wondering how to configure a script with preg replace to strip out images and leave only the alt tags in place. This is for a drupal theme. The code I have that supposedly works (but doesn't on my machine) is:
This goes in the "Block.TPL.PHP file in the theme folder.
The original poster said this works on his site but on mine, I get an error saying too many ")"
Basically what I want is to strip all images and leave just the alt tags for the page so it is 508 compliant.
print $block->subject; ?></h2>
$pattern = '/<img[^>]*?((alt="(.*?)".*?>)|>)/i';
$replacement = '(Image: $3)';
print preg_replace($pattern, $replacement, $block->content);