Revision history for EnhancedImageAction


Revision [19153]

Last edited on 2008-01-28 00:14:03 by VilVil [Modified links pointing to docs server]

No Differences

Revision [16905]

Edited on 2007-05-31 23:27:05 by VilVil [Reverted]
Additions:
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy ChristianBarthelemy} (heigth+width+openfull)
return preg_match("/^[0-9]+\%?$/",$input) ? TRUE : FALSE;
if ((is_array($image)) && ($alt))
if (!is_length($width) || !is_length($height)) {
$width = $image[0];
$height = $image[1];
$output.="<img ";
if ($class) {$output.="class=\"".$class."\" ";}
$output.="src=\"".$url."\" ";
if ($alt) {$output.="alt=\"".$alt."\" ";}
if ($title && !$link) {$output.="title=\"".$title."\" ";}
$output.="width=\"".$width."\" height=\"".$height."\" />";
//link?
if ($link && !$title) {$output = $this->Link($link, "", $output, 1, 0, 0);}
elseif ($link && $title) {$output = $this->Link($link, "", $output, 1, 0, $title);}
//make the output save and print it
$output = $this->ReturnSafeHTML($output);
print($output);
elseif (!$alt) {echo 'The necessary parameter alt was not provided';}
else {echo 'The image could not be found or it was no image. Please check the url';}
?>
%%
Note that we have to change the function Link in the wikka.php, too:
changing:
%%(php) return $url ? "<a class=\"ext\" href=\"$url\" >$text</a>$external_link_tail" : $text;%%
to:
%%(php)return $url ? "<a class=\"ext\" href=\"$url\" title=\"$title\">$text</a>$external_link_tail" : $text;%%
----
CategoryDevelopmentActions
Deletions:
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy ChristianBarthelemy} (heigth width openfull)
return preg_match("/^[0-9] \%?$/",$input) ? TRUE : FALSE;
if ((is_array($image))


Revision [16703]

Edited on 2007-05-31 10:38:21 by MnqA5u [Reverted]
Additions:
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy ChristianBarthelemy} (heigth width openfull)
return preg_match("/^[0-9] \%?$/",$input) ? TRUE : FALSE;
if ((is_array($image))
Deletions:
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy ChristianBarthelemy} (heigth+width+openfull)
return preg_match("/^[0-9]+\%?$/",$input) ? TRUE : FALSE;
if ((is_array($image)) && ($alt))
if (!is_length($width) || !is_length($height)) {
$width = $image[0];
$height = $image[1];
$output.="<img ";
if ($class) {$output.="class=\"".$class."\" ";}
$output.="src=\"".$url."\" ";
if ($alt) {$output.="alt=\"".$alt."\" ";}
if ($title && !$link) {$output.="title=\"".$title."\" ";}
$output.="width=\"".$width."\" height=\"".$height."\" />";
//link?
if ($link && !$title) {$output = $this->Link($link, "", $output, 1, 0, 0);}
elseif ($link && $title) {$output = $this->Link($link, "", $output, 1, 0, $title);}
//make the output save and print it
$output = $this->ReturnSafeHTML($output);
print($output);
elseif (!$alt) {echo 'The necessary parameter alt was not provided';}
else {echo 'The image could not be found or it was no image. Please check the url';}
?>
%%
Note that we have to change the function Link in the wikka.php, too:
changing:
%%(php) return $url ? "<a class=\"ext\" href=\"$url\" >$text</a>$external_link_tail" : $text;%%
to:
%%(php)return $url ? "<a class=\"ext\" href=\"$url\" title=\"$title\">$text</a>$external_link_tail" : $text;%%
----
CategoryDevelopmentActions


Revision [13679]

Edited on 2006-03-31 08:38:59 by VilVil [Reverted]
Additions:
return preg_match("/^[0-9]+\%?$/",$input) ? TRUE : FALSE;
$width = $image[0];
$height = $image[1];
elseif ($link && $title) {$output = $this->Link($link, "", $output, 1, 0, $title);}
Deletions:
return preg_match("/^[0-9]+\%?$/",$input) ? TRUE : FALSE;
$width = $image[0];
$height = $image[1];
elseif ($link && $title) {$output = $this->Link($link, "", $output, 1, 0, $title);}


Revision [8579]

Edited on 2005-05-28 11:41:02 by JavaWoman [move to subcategory + ypot]
Additions:
=====Enhanced Image Action=====
CategoryDevelopmentActions
Deletions:
=====Enhances Image Action=====
CategoryDevelopment


Revision [7116]

Edited on 2005-04-05 10:49:14 by TimoK [Quick (dirty) fix for "Can't redeclare already declared function" error]
Additions:
if (!function_exists('is_length')) {
function is_length($input) {
return preg_match("/^[0-9]+\%?$/",$input) ? TRUE : FALSE;
Deletions:
function is_length($input) {
return preg_match("/^[0-9]+\%?$/",$input) ? true : false;


Revision [7068]

Edited on 2005-04-01 19:01:59 by TimoK [Fixed a typo; solved JWs 7) ;)]
Additions:
// function to check if a string is a valid Length as specified in the XHTML DTDs
function is_length($input) {
return preg_match("/^[0-9]+\%?$/",$input) ? true : false;
if ($param == 'height') {$height=$this->htmlspecialchars_ent($vars['height']);}
if (!is_length($width) || !is_length($height)) {
$width = $image[0];
$height = $image[1];
Deletions:
if ($param == 'heigth') {$height=$this->htmlspecialchars_ent($vars['height']);}
if (!isset($width)) $width = $image[0];
if (!isset($height)) $height = $image[1];


Revision [7067]

Edited on 2005-04-01 18:37:04 by TimoK [Two negations were missing for width and height]
Additions:
if (!isset($width)) $width = $image[0];
if (!isset($height)) $height = $image[1];
Deletions:
if (isset($width)) $width = $image[0];
if (isset($height)) $height = $image[1];


Revision [7056]

Edited on 2005-04-01 15:47:32 by NilsLindenberg [small code change. note about change to function Link]
Additions:
if ($title && !$link) {$output.="title=\"".$title."\" ";}
if ($link && !$title) {$output = $this->Link($link, "", $output, 1, 0, 0);}
elseif ($link && $title) {$output = $this->Link($link, "", $output, 1, 0, $title);}
Note that we have to change the function Link in the wikka.php, too:
changing:
%%(php) return $url ? "<a class=\"ext\" href=\"$url\" >$text</a>$external_link_tail" : $text;%%
to:
%%(php)return $url ? "<a class=\"ext\" href=\"$url\" title=\"$title\">$text</a>$external_link_tail" : $text;%%
Deletions:
if ($title) {$output.="title=\"".$title."\" ";}
if ($link) {$output = $this->Link($link, "", $output, 1, 0, 0);}


Revision [7010]

Edited on 2005-03-30 12:07:58 by NilsLindenberg [small code corrections]
Additions:
$link = $class = $output = $title = $width = $height = NULL;
if (isset($width)) $width = $image[0];
if (isset($height)) $height = $image[1];
Deletions:
$link = $url = $class = $output = $alt = "";
$title = "WikiImage";
$width = $height = NULL;
if (!$width) $width = $image[0];
if (!$height) $height = $image[1];


Revision [7009]

Edited on 2005-03-30 12:03:42 by NilsLindenberg [small code corrections]
Additions:
* @input integer $height optional: alternative heigth for the image;
$width = $height = NULL;
if ($param == 'heigth') {$height=$this->htmlspecialchars_ent($vars['height']);}
if (!$height) $height = $image[1];
$output.="width=\"".$width."\" height=\"".$height."\" />";
Deletions:
* @input integer $heigth optional: alternative heigth for the image;
$width = $heigth = 0;
if ($param == 'heigth') {$heigth=$this->htmlspecialchars_ent($vars['heigth']);}
if (!$heigth) $heigth = $image[1];
$output.="width=\"".$width."\" heigth=\"".$heigth."\" />";


Revision [6813]

Edited on 2005-03-21 13:33:57 by NilsLindenberg [another code-update]
Additions:
if (!$width) $width = $image[0];
if (!$heigth) $heigth = $image[1];
$output.="width=\"".$width."\" heigth=\"".$heigth."\" />";
Deletions:
if ($width) {$output.="width=\"".$image[0]."\" ";}
else {$output.="width=\"".$width."\" ";}
if ($heigth) {$output.="heigth=\"".$image[1]."\" ";}
else {$output.="width=\"".$heigth."\" ";}
$output.=" />";


Revision [6811]

Edited on 2005-03-21 13:24:40 by NilsLindenberg [code update]
Additions:
* if you don't assign a link to the image).
* Syntax:
* {{image url ="http://www.example.com/example.jpg" alt="describing text" [link="http://www.example.com] [heigth=""] [width=""] [class="class"]}}
* @copyright Copyright © ?
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @input string $alt mandatory: alternative text for the image;
* @uses cleanUrl();
//sanatizing url and proofing if it is an image
$image = getimagesize($url);
//if it is an image, prepare the output
if ((is_array($image)) && ($alt))
$output.="<img ";
if ($class) {$output.="class=\"".$class."\" ";}
$output.="src=\"".$url."\" ";
if ($alt) {$output.="alt=\"".$alt."\" ";}
if ($title) {$output.="title=\"".$title."\" ";}
if ($width) {$output.="width=\"".$image[0]."\" ";}
else {$output.="width=\"".$width."\" ";}
if ($heigth) {$output.="heigth=\"".$image[1]."\" ";}
else {$output.="width=\"".$heigth."\" ";}
$output.=" />";
//link?
if ($link) {$output = $this->Link($link, "", $output, 1, 0, 0);}
//make the output save and print it
$output = $this->ReturnSafeHTML($output);
print($output);
elseif (!$alt) {echo 'The necessary parameter alt was not provided';}
else {echo 'The image could not be found or it was no image. Please check the url';}
Deletions:
* if you don't assign a link to the image).
* @input string $alt optional: alternative text for the image;
//preparing the output
$output.="<img ";
if ($class) {$output.="class=\"".$class."\" ";}
$output.="src=\"".$url."\" ";
if ($alt) {$output.="alt=\"".$alt."\" ";}
if ($title) {$output.="title=\"".$title."\" ";}
if ($width) {$output.="width=\"".$width."\" ";}
if ($heigth) {$output.="heigth=\"".$heigth."\" ";}
$output.=" />";
//link?
if ($link) {$output = $this->Link($link, "", $output, 1, 0, 0);}
//make the output save and print it
$output = $this->ReturnSafeHTML($output);
print($output);


Revision [6810]

Edited on 2005-03-21 12:55:21 by NilsLindenberg [see todo list of the action]
Additions:
* - handling when no url and/or alternative text is/are provided
* - documentation for src (also possible instead of url)
* - option to open "full-image" in another window?
$link = $url = $class = $output = $alt = "";
Deletions:
* @input mixed $openfull optinal: if different from nothing it will link to open the full size image
* in a new window;
* default: FALSE;
* - handling when no url is provided
* -documentation for src (also possible)
$link = $url = $class = $output = "";
$alt = "image";
$openfull = FALSE;
if (($param == 'openfull') && (!$link)) {$openfull=TRUE;}
if ($openfull) {$output.="<a href=\"".$url."\" target=\"_blank\" >";}
if ($openfull) {$output.="</a>";}


Revision [6809]

Edited on 2005-03-21 12:30:30 by NilsLindenberg [added christian]
Additions:
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy ChristianBarthelemy} (heigth+width+openfull)
Deletions:
* @author ?


Revision [6808]

Edited on 2005-03-21 12:29:08 by NilsLindenberg ["openfull" correction, default values, documentation]
Additions:
=====Enhances Image Action=====

>>==See also:==
Documentation: EnhancedImageActionInfo.>>This is the development page for the enhanced image action.::c::


The code here below is just a quick modification to the offical image action code. Only works from release 1.1.6.0!

%%(php)
<?php
/**
* Displays an image.
*
* You have to specify the url for the location of the image. In contrary to inline images you can set the
* apperance of the image better:
*
* You can specify "width" and "height" for the image (note that the image is just displayed different, it does
* not save any bandwidth), set a target link or make the full size image open in a new window (only possible
* if you don't assign a link to the image).
*
* @package Actions
* @subpackage ?
* @name image
*
* @author ?
* @author ?
* @author {@link http://wikka.jsnx.com/NilsLindenberg NilsLindenberg} (default values, minor corrections)
*
* @version 0.9
* @since ?
*
* @input string $url mandatory: url of the image to be displayed;
* @input string $link optional: target link for image (optional). Supports URL, WikiName links,
* InterWiki links etc.;
* default: none;
* @input string $alt optional: alternative text for the image;
* default: none;
* @input integer $width optional: alternative width for the image;
* default:
* @input integer $heigth optional: alternative heigth for the image;
* default:
* @input string $class optional: a class for the image;
* default: none;
* @input mixed $openfull optinal: if different from nothing it will link to open the full size image
* in a new window;
* default: FALSE;
* @output the given image;
*
* @todo - do we need to pass the output through SafeHtml?
* - handling when no url is provided
* -documentation for src (also possible)
*/

//setting default values
$link = $url = $class = $output = "";
$title = "WikiImage";
$alt = "image";
$width = $heigth = 0;
$openfull = FALSE;

//getting the paramters
if (is_array($vars))
{
foreach ($vars as $param => $value)
{
if ($param == 'src' and $vars['url'] == '') {$vars['url']=$value;}
if ($param == 'title') {$title=$this->htmlspecialchars_ent($vars['title']);}
if ($param == 'class') {$class=$this->htmlspecialchars_ent($vars['class']);}
if ($param == 'alt') {$alt=$this->htmlspecialchars_ent($vars['alt']);}
if ($param == 'width') {$width=$this->htmlspecialchars_ent($vars['width']);}
if ($param == 'heigth') {$heigth=$this->htmlspecialchars_ent($vars['heigth']);}
if ($param == 'link') {$link=$this->cleanUrl(trim($vars['link']));}
if (($param == 'openfull') && (!$link)) {$openfull=TRUE;}
}
}
$url = $this->cleanUrl(trim($vars['url']));

//preparing the output
if ($openfull) {$output.="<a href=\"".$url."\" target=\"_blank\" >";}
$output.="<img ";
if ($class) {$output.="class=\"".$class."\" ";}
$output.="src=\"".$url."\" ";
if ($alt) {$output.="alt=\"".$alt."\" ";}
if ($title) {$output.="title=\"".$title."\" ";}
if ($width) {$output.="width=\"".$width."\" ";}
if ($heigth) {$output.="heigth=\"".$heigth."\" ";}
$output.=" />";
if ($openfull) {$output.="</a>";}

//link?
if ($link) {$output = $this->Link($link, "", $output, 1, 0, 0);}

//make the output save and print it
$output = $this->ReturnSafeHTML($output);
print($output);
?>
%%
----
Deletions:
=====Enhances Image Action=====

>>==See also:==
Documentation: EnhancedImageActionInfo.>>This is the development page for the enhanced image action.::c::


The code here below is just a quick modification to the offical image action code. Only works from release 1.1.6.0!

%%(php)
<?php
/*
"image" action

Parameters:
url - URL of image to be embedded
link - target link for image (optional). Supports URL, WikiName links, InterWiki links etc.
title - title text displayed when mouse hovers above image
class - a class for the image
alt - an alt text
width - optional width
heigth - optional heigth
openfull - if different from nothing it will link to open the full size image in a new window

*/

if (is_array($vars))
{
foreach ($vars as $param => $value)
{
if ($param == 'src' and $vars['url'] == '') {$vars['url']=$value;}
if ($param == 'title') {$title=$this->htmlspecialchars_ent($vars['title']);}
if ($param == 'class') {$class=$this->htmlspecialchars_ent($vars['class']);}
if ($param == 'alt') {$alt=$this->htmlspecialchars_ent($vars['alt']);}
if ($param == 'width') {$width=$this->htmlspecialchars_ent($vars['width']);}
if ($param == 'heigth') {$heigth=$this->htmlspecialchars_ent($vars['heigth']);}
}
}
$url = $this->cleanUrl(trim($vars['url']));
$output="";

if ($openfull) {$output.="<a href=\"".$url."\" target=\"_blank\" >";}
$output.="<img ";
if ($class) {$output.="class=\"".$class."\" ";}
$output.="src=\"".$url."\" ";
if ($alt) {$output.="alt=\"".$alt."\" ";}
if ($title) {$output.="title=\"".$title."\" ";}
if ($width) {$output.="width=\"".$width."\" ";}
if ($heigth) {$output.="heigth=\"".$heigth."\" ";}
$output.=" />";
if ($openfull) {$output.="<a>";}

// link?
if ($link = $vars['link'])
{
$output = $this->Link($link, "", $output, 1, 0, 0);
}

$output = $this->ReturnSafeHTML($output);
print($output);

?>
%%
----


Revision [5649]

Edited on 2005-02-05 14:21:12 by ChristianBarthelemy [Limitation of the code: only works from Wikka 1.1.6.0]
Additions:
The code here below is just a quick modification to the offical image action code. Only works from release 1.1.6.0!
Deletions:
The code here below is just a quick modification to the offical image action code.


Revision [5431]

Edited on 2005-02-01 12:41:33 by NilsLindenberg [maior bugfix]
Additions:
class - a class for the image
width - optional width
heigth - optional heigth
openfull - if different from nothing it will link to open the full size image in a new window
if ($param == 'width') {$width=$this->htmlspecialchars_ent($vars['width']);}
if ($param == 'heigth') {$heigth=$this->htmlspecialchars_ent($vars['heigth']);}
Deletions:
class - a class for the image
width - optional width
heigth - optional heigth
openfull - if different from nothing it will link to open the full size image in a new window
if ($param == 'width') {$alt=$this->htmlspecialchars_ent($vars['width']);}
if ($param == 'heigth') {$alt=$this->htmlspecialchars_ent($vars['heigth']);}


Revision [5310]

Edited on 2005-01-28 09:58:56 by ChristianBarthelemy [Simple enhancement to the image action]
Additions:
The code here below is just a quick modification to the offical image action code.
%%(php)
<?php
/*
"image" action
Parameters:
url - URL of image to be embedded
link - target link for image (optional). Supports URL, WikiName links, InterWiki links etc.
title - title text displayed when mouse hovers above image
class - a class for the image
alt - an alt text
width - optional width
heigth - optional heigth
openfull - if different from nothing it will link to open the full size image in a new window
*/
if (is_array($vars))
{
foreach ($vars as $param => $value)
{
if ($param == 'src' and $vars['url'] == '') {$vars['url']=$value;}
if ($param == 'title') {$title=$this->htmlspecialchars_ent($vars['title']);}
if ($param == 'class') {$class=$this->htmlspecialchars_ent($vars['class']);}
if ($param == 'alt') {$alt=$this->htmlspecialchars_ent($vars['alt']);}
if ($param == 'width') {$alt=$this->htmlspecialchars_ent($vars['width']);}
if ($param == 'heigth') {$alt=$this->htmlspecialchars_ent($vars['heigth']);}
}
}
$url = $this->cleanUrl(trim($vars['url']));
$output="";
if ($openfull) {$output.="<a href=\"".$url."\" target=\"_blank\" >";}
$output.="<img ";
if ($class) {$output.="class=\"".$class."\" ";}
$output.="src=\"".$url."\" ";
if ($alt) {$output.="alt=\"".$alt."\" ";}
if ($title) {$output.="title=\"".$title."\" ";}
if ($width) {$output.="width=\"".$width."\" ";}
if ($heigth) {$output.="heigth=\"".$heigth."\" ";}
$output.=" />";
if ($openfull) {$output.="<a>";}
// link?
if ($link = $vars['link'])
{
$output = $this->Link($link, "", $output, 1, 0, 0);
}
$output = $this->ReturnSafeHTML($output);
print($output);
?>
%%
Deletions:
===Why a modification to the image action?===
The aim of this enhancement to the official image action is to:
- support HEIGTH and WIDTH parameters
- allow to create a link opening a new html page to display a full size image
===Usage===
Just use the action as usual (AddingImages) and add the optional parameters:
- WIDTH to define the width of the image to be displayed
- HEIGTH to define the heigth of the image to be displayed
- OPENFULL will create an anchor link to the image URL that will open a new html page to display the full size image when clicking on the picture
All 3 new parameters are optionals - OPENFULL is considered as TRUE when different from nothing.
""{{image class="center" alt="blabla" title="blabla" width="25" heigth="12" openfull="whatever"}}


Revision [5296]

Edited on 2005-01-28 06:52:26 by ChristianBarthelemy [Simple enhancement to the image action]
Additions:
=====Enhances Image Action=====
Documentation: EnhancedImageActionInfo.>>This is the development page for the enhanced image action.::c::
===Why a modification to the image action?===
The aim of this enhancement to the official image action is to:
- support HEIGTH and WIDTH parameters
- allow to create a link opening a new html page to display a full size image
===Usage===
Just use the action as usual (AddingImages) and add the optional parameters:
- WIDTH to define the width of the image to be displayed
- HEIGTH to define the heigth of the image to be displayed
- OPENFULL will create an anchor link to the image URL that will open a new html page to display the full size image when clicking on the picture
All 3 new parameters are optionals - OPENFULL is considered as TRUE when different from nothing.
""{{image class="center" alt="blabla" title="blabla" width="25" heigth="12" openfull="whatever"}}
Deletions:
=====xxxxx Action=====
Documentation: xxxxxActionInfo.>>This is the development page for the xxxxx action.::c::
//This page is a **template**. It belongs to CategoryTemplate (which contains more handy templates). To create an action development page, [[http://wikka.jsnx.com/ActionTemplate/clone clone this page]] to a page called **xxxxxAction** (where xxxxx is the (capitalized) name of the action), replace all occurrences of 'xxxxx' with the name of the action and replace this paragraph with the actual content.//


Revision [5293]

The oldest known version of this page was created on 2005-01-28 06:35:23 by ChristianBarthelemy [Simple enhancement to the image action]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki