Changeset 77199 in spip-zone
- Timestamp:
- Oct 13, 2013, 2:39:01 PM (8 years ago)
- Location:
- _plugins_/respim/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/respim/trunk/paquet.xml
r77191 r77199 2 2 prefix="respim" 3 3 categorie="multimedia" 4 version="0.3. 0"4 version="0.3.1" 5 5 etat="dev" 6 6 compatibilite="[3.0.12-dev;3.0.*]" -
_plugins_/respim/trunk/respim_options.php
r77191 r77199 1 1 <?php 2 2 /** 3 * Options du plugin Responsive Images au chargement3 * Options du plugin Responsive Images 4 4 * 5 5 * @plugin Responsive Images … … 23 23 * @return string 24 24 */ 25 function respim_embed($img, $rwd_images, $width, $height){ 26 25 function respim_markup($img, $rwd_images, $width, $height){ 26 $class = extraire_attribut($img,"class"); 27 if (strpos($class,"respim")!==false) return $img; 27 28 ksort($rwd_images); 28 29 $cid = "c".crc32(serialize($rwd_images)); 29 30 $style = 30 "img.$cid{opacity:0.01;filter:alpha(opacity=1);width:{$width}px;max-width:100%;height:auto;} 31 b.$cid{background-size:100%;background-repeat:no-repeat;display:inline-block;max-width:100%} 32 "; 31 "img.respim{opacity:0.01;max-width:100%;height:auto;}" 32 ."b.respwrapper{background-size:100%;background-repeat:no-repeat;display:inline-block;max-width:100%}"; 33 if ($class) $class = " $class"; 34 $class = "$cid$class"; 35 $img = inserer_attribut($img,"class","respim-fallback $class"); 33 36 34 37 // image de fallback fournie ? … … 54 57 } 55 58 $style .= "b.$cid{background-image:url($file);}"; 56 $style .= implode(" \n",$medias);59 $style .= implode("",$medias); 57 60 58 $class = extraire_attribut($img,"class");59 if ($class) $class = " $class";60 $class = "responsive $cid$class";61 61 62 $out = "<!--[if IE]>$img<![endif]--> ";62 $out = "<!--[if IE]>$img<![endif]-->\n"; 63 63 $img = inserer_attribut($img,"src",$fallback_file); 64 $img = inserer_attribut($img,"class", $class);65 $img = inserer_attribut($img,"onmousedown","var i=window.getComputedStyle(this.parentNode).backgroundImage.replace(/\W \)$/,'').replace(/^url\(\W|/,'');this.src=(i&&i!='none'?i:this.src);");66 $out .= "<!--[if !IE]--><b class=\" $cid\">$img</b><style>$style</style><!--[endif]-->";64 $img = inserer_attribut($img,"class","respim $class"); 65 $img = inserer_attribut($img,"onmousedown","var i=window.getComputedStyle(this.parentNode).backgroundImage.replace(/\W?\)$/,'').replace(/^url\(\W?|/,'');this.src=(i&&i!='none'?i:this.src);"); 66 $out .= "<!--[if !IE]--><b class=\"respwrapper $cid\">$img</b>\n<style>$style</style><!--[endif]-->"; 67 67 68 68 return $out; … … 70 70 71 71 /** 72 * extrait les infos d'une image, 73 * calcule les variantes en fonction des breakpoints 74 * si l'image est de taille superieure au plus petit breakpoint 75 * et renvoi un markup responsive si il y a lieu 76 * 72 77 * @param string $img 73 78 * @param array $bkpt … … 76 81 function respim_image($img, $bkpt = array(320,480,780)){ 77 82 if (!$img) return $img; 83 if (strpos($img,"respim")!==false 84 OR strpos($img,"spip_logos")!==false) 85 return $img; 86 78 87 if (!function_exists("taille_image")) 79 88 include_spip("inc/filtres"); … … 102 111 return $img; 103 112 113 // calculer les variantes d'image sur les breakpoints 104 114 $large = ""; 105 115 foreach($bkpt as $wk){ … … 109 119 } 110 120 121 // l'image de fallback en jpg tres compresse 111 122 if (function_exists("image_aplatir")){ 112 123 // image de fallback : la plus petite en jpg compresse … … 115 126 } 116 127 117 // pour les autres (les mobiles ou autres trucs tactiles apparentes, sauf android2, donc) 118 // on renvoie un conteneur svg 119 120 return respim_embed($img,$images,$w,$h); 128 // generer le markup 129 return respim_markup($img,$images,$w,$h); 121 130 } 122 131 132 /** 133 * Traiter les images de la page et les passer en responsive 134 * si besoin 135 * 136 * @param $texte 137 * @return mixed 138 */ 123 139 function respim_affichage_final($texte){ 124 140 if ($GLOBALS['html']){
Note: See TracChangeset
for help on using the changeset viewer.