Images alt and title

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
susscorfa
Posts: 7
Joined: Thu 16. Feb 2006, 12:18

Images alt and title

Post by susscorfa »

hi
i want too add some text in the alt en title tages of <img src=""> is there a possebility too do that? i could not find any possibilaty

i'm using the most uptodate version of phpwcms
jscholtysik

Post by jscholtysik »

User avatar
Kosse
Posts: 1066
Joined: Thu 9. Sep 2004, 12:08
Location: Brussels, Belgium
Contact:

Post by Kosse »

Hi susscorfa, welcome to phpwcms forum,

Joachim is right (he rarely is wrong) :D, that is one way to do it (with article CONTENT PARTS) other way is to download the RT (replacement tags) PACKAGE at SourceForge Phpwcms-Addon project and use the RT with image + alt + tile + size... whatever you want.
You will download like 25 rep tags working as for today.

Otherwise, here is the individual code, just place it in phpwcms_template/inc_script/frontend_render/reptag_IMAGE_TAG.php

Then in any article/template you can use it ;)

Code: Select all

<?php

/********************************************
From:
SourceForge Project: https://sourceforge.net/projects/phpwcms-addon/
Support: http://dev-brenner-b-e or http://www.phpwcms.de/forum/

REPTAG CODE: {IMAGE_SIZE:x:y:z} for size
REPTAG CODE: {IMAGE_AT:x:y} for ALT and TITLE attribute
REPTAG CODE: {IMAGE_ROLL:x:y:z:url} for ROLLOVER function

Developer(s): pSouper, breistch, Kosse
phpWCMS Version: all (frontend_render enabled)

Description:
Method based on My {RT}'s great idea by pSouper, altered version of a function found in include/inc_front/front.func.inc.php
These are 3 IMAGE replacement tags, if u want to add your own, just increase increase $search[n] & $replace[n] 

1) You can set SIZE, with {IMAGE_SIZE:x:y:z} where x is the name of the picture, y width and z for height
2) You can set ALT and TITLE text, with {IMAGE_AT:x:y} where x is the name of the picture, y the name of ALT and TITLE attributes
3) You can set ROLLOVER function, with {IMAGE_ROLL:x:y:z:url}  where url is the URL of the link, x picture's name, y rollover picture's name and z ALT, TEXT and NAME attribute
Caution: don't forget to upload you images in /picture folder and when you put your images names it is "image.gif" or "image.jpg" or "image.png" not just "image" ;)

Installation Summary: Just this file to add, nothing to edit.

Mod version: final
Download: https://sourceforge.net/projects/phpwcms-addon/

Support:
http://www.phpwcms.de/forum

********************************************/

// CODE
// My ImageTag function
   	$content["all"] = (myImageTag ($content["all"]));// parse the whole webpage $content["all"] is the fully rendered webpage your site displays  
   	function myImageTag($string) {   // parse the $string and replace all possible instances of the following {RT}'s

// Define new {RT}'s here....increase $search[n] & $replace[n] ;)      

   // place an image of given dimentions // usage: {IMAGE_SIZE:x,y}  by breitsch
   	$search[0]      = '/\{IMAGE_SIZE:(.*?):(.*?):(.*?)\}/';
   	$replace[0]      = '<img src="picture/$1" border="0" width="$2" height="$3" alt=""';

	// insert non db image standard plus ALT and TITLE attribute  // usage: {IMAGE_AT:x,y}  by Kosse
	$search[1]		= '/\{IMAGE_AT:(.*?):(.*?)\}/';
	$replace[1]	= '<img src="picture/$1" border="0" alt="$2" title="$2" />';
	
	//insert  non db image standard plus ALT and TITLE and ROLLOVER attribute // usage: {IMAGE_ROLL:x:y:z:url}  by Kosse
	$search[2]		= '/\{IMAGE_ROLL:(.*?):(.*?):(.*?):(.*?)\}/';
	$replace[2]		= '<a href="$4" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'$3\',\'\',\'picture/$2\',0)"><img src="picture/$1" name="$3" border="0" alt="$3" title="$3" /></a>';

   // The replacements are done here....
   	$string = preg_replace($search, $replace, $string);
	$string = str_replace('\'', ''', $string);
	$string = str_replace('&quot;', '"', $string);
	return $string;// spit out the final webpage for display
}
?> 
Cheers
susscorfa
Posts: 7
Joined: Thu 16. Feb 2006, 12:18

Post by susscorfa »

thx for the fast anwser i'm gone look at it this afternoon
susscorfa
Posts: 7
Joined: Thu 16. Feb 2006, 12:18

Post by susscorfa »

i accomplished it by adding this code in front.func.inc.php around line 315 now caption can be filed in like this caption txt|alt txt|link|title txt

Code: Select all

			// takes care of making een title for a immage (added by bart)
				$titel = null;
			if(isset($caption[3])){
				$titel = ' title="'.$caption[3].'"';
			}		
		
			$list_img_temp  = '<img src="'.PHPWCMS_IMAGES.$thumb_image[0].'" '.$thumb_image[3].$image_border.$image_imgclass;
			$list_img_temp .= ' alt="'.$caption[1].'"';
			$list_img_temp .=$titel;//toegevoegd bart
			$list_img_temp .= '/>';
Post Reply