Quote from: le_block at Nov 07, 2008, 06:55 AM
Can you explain this technique a little more detailed? How to edit? The code of the TV itself? this could be a good starting point.
The idea is to add alt-text to URL of image-TV value.
For example, if Your image URL is assets/images/photo.jpg, and You want to add alt-text "This is my family", You need just modify URL of image-TV by hands like this: assets/images/photo.jpg#This is my family (this URL will correctly opened by any browser!).
The second step is to enable little plugin.
How It works: plugin searches image URLs with "#" additions, adds alt-attribute and cleans "#" addition from img-src!
Just try this (and if this idea will be useful, I will add plugin to official repository)
/*
Name: Alta
Version: 1.0.0
Author: Urique ([email protected])
Date: 2008-11-04
*/
$e = &$modx->Event;
switch ($e->name)
{
case 'OnWebPagePrerender':
$out = &$modx->documentOutput;
$search = '/(<\s*img[^>]+)(src\s*=\s*["|\'])([^"|^\']*)#([^"|^\']*)(["|\'])/i';
$replace = '\\1\\2\\3\\5 alt=\\5\\4\\5 title=\\5\\4\\5';
$out = preg_replace($search,$replace,$out);
break;
default:
return;
break;
}
How to install:
1. Create plugin with name "Alta" and paste the code
2. Check "OnWebPagePrerender" event and save it
3. Make sure that plugin is run first on "OnWebPagePrerender" event
4. Add #-addition to any URL of image-tv and refresh FrontEnd page!
Waiting 4 comments…