ExtendedImagesWithLinks

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


<#>? To create a new cookbook entry, fill in or remove the sections below.

Goal

A script allows to add images (with a relative path) which are linked.

Solution

solved

Code should be look like this:

[:imageincllink http://www.somedomain.cc/;/path/to/image.jpg:]

or

[:imageincllink /path/to/link.html;/path/to/image.jpg:]

or even with anchors

[:imageincllink #top;/path/to/image.jpg:]
( anchor can be defined with [[#name]] )

 # function to retrive width and height of the included image
 function getimagedimension($path)
 {
 if($path!="")
 {
   $fullpath = getcwd().trim($path);
   $sizearray=getimagesize($fullpath);
   return $sizearray[3];
 }
 }

 # include linked image
 $BrowseDirectives['/\\[:imageincllink (.*):\\]/e'] = 'imginclink("$1")';
 function imginclink($urlimg) {
   $arrayt = explode (";",$urlimg);
   $urlimgstr = '<a href="'.$arrayt[0].'"><img src="'.$arrayt[1].'" '.getimagedimension($arrayt[1]).'" border="0" alt=""></a>';
   return Keep($urlimgstr);
 }

Discussion

I don't want do this

   [[http://www.domain.cc/path ThisSite:/path/to/image.jpg]]  

because in the result is an unwanted <a class="urllink" ...]

and i want to get the size of the image by php-script and add width="..." and height="..." in the code ...

See Also

Only for images with relative paths: (include in local/config.php)

 # include image with relative path, width, height but no <br> at the end
 $DoubleBrackets['/\\[:relinclnobr (.*):\\]/e'] =  "Keep(RelInclNoBr('$1'))";
 function RelInclNoBr($img) {
   $imgstr = "<img src=\"".$img."\" ".getimagedimension($img)." border=\"0\" alt=\"\">";
   return $imgstr;
 }

 # include image with relative path, width, height with <br> at the end
 $DoubleBrackets['/\\[:relincl (.*):\\]/e'] = "Keep(RelIncl('$1'))";
 function RelIncl($img) {
    $imgstr = "<img src=\"".$img."\" ".getimagedimension($img)." border=\"0\" alt=\"\"><br>";
   return $imgstr;
 }

Usage:

 [:relincl /path/to/image.jpg :]

or

add RelIncl on a single line in your local/localmap.txt

and

Use:
RelIncl:/path/to/image.jpg

History

Comments & Bugs

Contributors

Copyright

Always GPL pmwiki-2.2.113 -- Last modified by {{el}}?

from IP: 85.171.160.186 ip should be disabled by default for security reasons