Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-01-2009, 08:51 PM   PM User | #1
jrockford1
New to the CF scene

 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jrockford1 is an unknown quantity at this point
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.

PHP Code:
print $block->subject; ?></h2>
<div class="content">
<?php
$pattern 
'/<img[^>]*?((alt="(.*?)".*?>)|>)/i';
$replacement '(Image: $3)';
print 
preg_replace($pattern$replacement$block->content);
?>
jrockford1 is offline   Reply With Quote
Reply

Bookmarks

Tags
drupal, preg_replace

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:01 PM.


Advertisement
Log in to turn off these ads.