[themes] Alt text with preg_replace for accessibility

Mark Hope mark at markhope.net
Tue Nov 7 18:13:08 UTC 2006


Thanks Ross,
I'll give the new preg_replace a go.

I've already explained to the client that there is no need for a text 
only site, as the design is xhtml/css and already accessible.
She only has limited knowledge of the subject and is being fairly 
insistent, so I'm implementing it anyway.

Cheers
Mark


On 7 Nov 2006, at 17:20, Ross Kendall wrote:

> 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 at drupal.org
>> http://lists.drupal.org/mailman/listinfo/themes
>>
> _______________________________________________
> themes mailing list
> themes at drupal.org
> http://lists.drupal.org/mailman/listinfo/themes
>



More information about the themes mailing list