Differences

This shows you the differences between two versions of the page.

deutsch:ersetzer_rts:frontend_render:random_image [2011/06/20 10:35]
Knut Heermann (flip-flop)
deutsch:ersetzer_rts:frontend_render:random_image [2018/06/03 18:09] (current)
Line 8: Line 8:
<code php>E.g. {GET_RANDOM_ALIAS_IMG_URL:picture/images/test}</code> <code php>E.g. {GET_RANDOM_ALIAS_IMG_URL:picture/images/test}</code>
-Forum: [[http://forum.phpwcms.org/viewtopic.php?p=57124#p57124|{GET_RANDOM_ALIAS_IMG_URL}]]+**Forum:** [[http://forum.phpwcms.org/viewtopic.php?p=57124#p57124|{GET_RANDOM_ALIAS_IMG_URL}]]
-Authors: tinoo, pepe(starter), RCS robin c. sherwood //(adapting and mixing up the code)// \\ +**Autoren:** tinoo, pepe(starter), RCS robin c. sherwood //(adapting and mixing up the code)// \\ 
-Last modified:  23.01.2006 created/mixed up+**Letze Änderung:** 23.01.2006 created/mixed up
-Filename: rt_get_random_alias_img_url.php+**Dateiname:** rt_get_random_alias_img_url.php
-Folder: /template/inc_script/frontend_render/+**Verzeichnis:** /template/inc_script/frontend_render/
-Switch: $phpwcms['allow_ext_render'] = 1; (/config/phpwcms/conf.inc.php) +**Schalter:** $phpwcms['allow_ext_render'] = 1; (/config/phpwcms/conf.inc.php)
---- ----
---- ----
 +\\
 +Die Verwendung ist denkbar einfach. Für jeden Stukturalias, der mit per Zufall ausgesuchten Bildern bestückt werden soll, legst Du ein Verzeichnis an, z.B. /picture/Image/structure-aliasname/.. \\
 +Der Upload kann per FTP erfolgen. \\
-Hier fehlt noch eine etwas genauere Erklärung.  +<file> 
-FIXME+<table style="background-image: url ({GET_RANDOM_ALIAS_IMG_URL:picture/Image}) 
 +<img src="{GET_RANDOM_ALIAS_IMG_URL:picture/Image}"> 
 +<a href="link-to-somewhere"><img src="{GET_RANDOM_ALIAS_IMG_URL:picture/Image}" border="0"></a> 
 +</file> 
 + 
 +\\ 
 +Datei: **/template/inc_script/frontend_render/rt_get_random_alias_img_url.php**
-Location: **/template/inc_script/frontend_render/rt_get_random_alias_img_url.php** 
<code php |h {GET_RANDOM_ALIAS_IMG_URL:image-path}|h > <code php |h {GET_RANDOM_ALIAS_IMG_URL:image-path}|h >
<?php <?php
Line 375: Line 383:
</code> </code>
 +\\
 +
 +===== V1.1 =====
 +Identisch mit der o.g. Version jedoch erweitert durch die Darstellung aller Bilder im angegebenen Verzeichnis mit Hilfe der LightBox //(Next/Prev)//.
 +
 +  * **{RANDOMX:SRC-LBNP:path:WIDTHxHEIGHT}** gibt den kompletten html-Anweisungssatz für die LightBox mit %%WIDTHxHEIGHT%% für die Thumbs zurück und stellt alle Bilddateien aus dem angegebenen Pfad in der LightBox dar.
 +    * Die LightBox stellt die Bilder in der Originalgröße dar.
 +    * Das Thumb wird lediglich verkleinert dargestellt, nicht neu gerechnet/abgelegt oder beschnitten //(cropping)//.
 +    * Update 21.06.11:
 +      - Das Thumb wird proportional verkleinert entsprechend den Größenangaben dargestellt //(Identisches Verfahren wie in den Bilder CPs - Das größte Teilungsverhältnis ist der Richtwert für beide Seiten)//.  
 +      - Korrektur beim Bildtyp.
 +
 +\\
 +**Beispiel:** ##%%{RANDOMX:SRC-LBNP:picture/upload/image/:200x150}%%##
 +
 +Das Zufallsvorschaubild //(Thumb)// wird mit einer maximalen Größe von 200x150px //(siehe oben "proportional")// dargestellt und verlinkt auf die LightBox, in der dann alle Bilder des Verzeichnisses in Originalgröße mit //(Next/Prev)// dargestellt werden können.
\\ \\
Line 383: Line 407:
<code php|h rt_randomX_img.php |h> <code php|h rt_randomX_img.php |h>
<?php <?php
-// KH 19.06.11 flip-flop: Random image from normal folder V1.1+// KH 21.06.11 flip-flop: Random image from normal folder V1.1
// ------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------
Line 392: Line 416:
function get_random_image_tagX($path) { function get_random_image_tagX($path) {
- // returns an random image from the give path+ // returns an random image from the given path
// it looks for image of following type: gif, jpg, jpeg, png // it looks for image of following type: gif, jpg, jpeg, png
- // {RANDOMX:path} willl return <img src="path/rand_image" />+ // {RANDOMX:path} will return <img src="path/rand_image" />
// {RANDOMX:SRC:path} will return absolute URI PHPWCMS_URL/path/rand_image // {RANDOMX:SRC:path} will return absolute URI PHPWCMS_URL/path/rand_image
// {RANDOMX:SRC-R:path} will return only relative path/rand_image // {RANDOMX:SRC-R:path} will return only relative path/rand_image
- // {RANDOMX:SRC-LB:path:%WIDTH%x%HEIGHT%} will return a complete html set for LightBox with WIDTHxHEIGHT for the thumb+ // {RANDOMX:SRC-LB:path:%WIDTH%x%HEIGHT%} will return a complete html set for LightBox with proportional WIDTHxHEIGHT for the thumb
// {RANDOMX:SRC-LBNP:path:%WIDTH%x%HEIGHT%} the same like SRC-LB with LightBox Next/Prev pictures from this folder // {RANDOMX:SRC-LBNP:path:%WIDTH%x%HEIGHT%} the same like SRC-LB with LightBox Next/Prev pictures from this folder
Line 454: Line 478:
closedir( $handle ); closedir( $handle );
} }
-  +
- +
// RANDOM // RANDOM
if(count($imgArray) && ($imageinfo = is_random_image($imgArray, $imgpath))) { if(count($imgArray) && ($imageinfo = is_random_image($imgArray, $imgpath))) {
Line 462: Line 485:
} else { } else {
 + // LightBox output
if ($tagX === 2 OR $tagX === 3) {  // SRC-LB OR SRC-LBNP: if ($tagX === 2 OR $tagX === 3) {  // SRC-LB OR SRC-LBNP:
initializeLightbox(); initializeLightbox();
// $x = '<img src="'.$path.'/'.urlencode($imageinfo['imagename']).'" '.$imageinfo[3].' border="0" alt="'.html_specialchars($imageinfo["imagename"]).'"'.HTML_TAG_CLOSE; // $x = '<img src="'.$path.'/'.urlencode($imageinfo['imagename']).'" '.$imageinfo[3].' border="0" alt="'.html_specialchars($imageinfo["imagename"]).'"'.HTML_TAG_CLOSE;
- $x  = '<a href="image_resized.php?format=jpg&q=85&imgfile='.$path.'/'.urlencode($imageinfo['imagename']).'" rel="lightbox[NextPrev]" target="_blank">'; + // Type of image 
- $x .= '<img src="image_resized.php?format=jpg&q=85&imgfile='.$path.'/'.urlencode($imageinfo['imagename']).'" class="image_img" alt="'.html_specialchars($imageinfo["imagename"]).'" height="'.$height.'" width="'.$width.'"></a>'.LF;+ $img_type = substr($imageinfo['mime'], 6); // e.g. image/jpeg -> jpeg 
 + if ($imageinfo['2'] == 2) $img_type .= '&q=85'; // Only if jpg = type Nr 2 
 +  
 + // Proportional image size 
 + $img_x = $imageinfo[0] / $width;  // z.B. 800 / 200 = 4,00 
 + $img_y = $imageinfo[1] / $height; // z.B. 532 / 100 = 5,32 
 +  
 + if ($img_x < $img_y) $width = $imageinfo[0] / $img_y; 
 + else $height = $imageinfo[1] / $img_x; 
 +  
 + $x  = '<a href="image_resized.php?format='.$img_type.'&imgfile='.$path.'/'.urlencode($imageinfo['imagename']).'" rel="lightbox[NextPrev]" target="_blank">'; 
 + $x .= '<img src="image_resized.php?format='.$img_type.'&imgfile='.$path.'/'.urlencode($imageinfo['imagename']).'" class="random-img" alt="'.html_specialchars($imageinfo["imagename"]).'" height="'.$height.'" width="'.$width.'"></a>'.LF;
$random_image = $imageinfo['imagename']; $random_image = $imageinfo['imagename'];
Line 473: Line 508:
if ($tagX === 3 ) {  // SRC-LBNP: if ($tagX === 3 ) {  // SRC-LBNP:
foreach ($imgArray as $key=>$value) { foreach ($imgArray as $key=>$value) {
- +
$imageinfo = @getimagesize($imgpath.$value);  // is it an image? $imageinfo = @getimagesize($imgpath.$value);  // is it an image?
if ($imageinfo) { if ($imageinfo) {
 +
 + $img_type = substr($imageinfo['mime'], 6); // e.g. image/jpeg -> jpeg
 + if ($imageinfo['2'] == 2) $img_type .= '&q=85'; // Only if jpg = type Nr 2
 +
if ($random_image != $value)  // No double image entry except the random image if ($random_image != $value)  // No double image entry except the random image
- $x .= '<a href="image_resized.php?format=jpg&q=85&imgfile='.$path.'/'.urlencode($value).'" rel="lightbox[NextPrev]" target="_blank"></a>'.LF;+ $x .= '<a href="image_resized.php?format='.$img_type.'&imgfile='.$path.'/'.urlencode($value).'" rel="lightbox[NextPrev]" target="_blank"></a>'.LF;
// $x .= '<img src="image_resized.php?format=jpg&q=85&imgfile='.$path.'/'.urlencode($value).'" class="image_img" alt="'.html_specialchars($value).'" height="'.$height.'" width="'.$width.'"></a>'.LF; // $x .= '<img src="image_resized.php?format=jpg&q=85&imgfile='.$path.'/'.urlencode($value).'" class="image_img" alt="'.html_specialchars($value).'" height="'.$height.'" width="'.$width.'"></a>'.LF;
} }
Line 484: Line 523:
} }
- +
return $x; return $x;
} elseif (($tagX === 1))  // SRC-R } elseif (($tagX === 1))  // SRC-R
return  $path . '/' . urlencode($imageinfo['imagename']); return  $path . '/' . urlencode($imageinfo['imagename']);
- else + else // SRC:
return PHPWCMS_URL . $path . '/' . urlencode($imageinfo['imagename']); return PHPWCMS_URL . $path . '/' . urlencode($imageinfo['imagename']);
} }
Line 504: Line 543:
// $string = str_replace('&#92;&#039;', '&#039;', $string); // $string = str_replace('&#92;&#039;', '&#039;', $string);
// $string = str_replace('&amp;quot;', '&quot;', $string); // $string = str_replace('&amp;quot;', '&quot;', $string);
 +
?> ?>
</code> </code>
 +
 +\\
deutsch/ersetzer_rts/frontend_render/random_image.1308558900.txt.gz · Last modified: 2018/06/03 18:07 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0