automaticaly insert links to tags if tag word occures in image description

wrote this function so if you type a word in the image description that is a tag it becomes a link to all the other occurences of this tag.

`function getImageDesc() {

if(!in_context(ZP_IMAGE)) return false;

global $_zp_current_image;

$desc = str_replace("rn", "n", $_zp_current_image->getDesc());

$result = query_full_array("SELECT `tags` FROM ". prefix('images'));

foreach($result as $row){

$alltags = $alltags.$row['tags'].",";

}

$result = query_full_array("SELECT `tags` FROM ". prefix('albums'));

foreach($result as $row){

$alltags = $alltags.$row['tags'].",";

}

$alltags = explode(",",$alltags);

$alltags = array_unique( $alltags);

foreach($alltags as $tag){

$replace="".$tag."";

$desc=str_replace($tag, $replace, $desc);

}

return str_replace("n", "
", $desc);

}`
Sign In or Register to comment.