Hi Mark,
You could try this: <?php $pattern = '/<img[^>]*?((alt="(.*?)".*?>)|>)/i'; $replacement = '(Image: $3)'; print preg_replace($pattern, $replacement, $content); ?>
However, I do not think this whole approach is needed. Web users who don't want to view images can disable them in their web browser - the job of the web designer is to make sure that the website works well either way. When I'm working on a design I always test with CSS and images disabled.
Cheers, Ross.
Mark Hope wrote:
Hi,
I'm creating a text only version of a site and would like to replace inline images with their alt text.
In my template files I have:
<?php print preg_replace("/<img[^>]+\>/i", "(image) ", $content) ?>
which replaces all images with: (image)
what code would I need to create output like: (Image description: THE ALT TEXT HERE)
and is this best practice?
Regards Mark
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes