No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Vous devez être membre et vous identifier pour publier un article.
Les visiteurs peuvent toutefois commenter chaque article par une réponse.

Réduire l'affichage d'images

Astuces de l’Infobrol (Développement)Article publié le 09/04/2005 12:36:20


Cette fonction de réduction proportionnelle d'images permet de mettre à l'échelle des images insérées au travers d'un texte.
Au départ de balises perso, on utilise la fonction preg_replace_call_back pour rendre l'image active et réduite.

  1. $texte='Une chaine avec du balisage perso dont une [baliseimage]http://unsite.com/photos/img-1.jpg[/baliseimage] et du texte à la suite et encore une image [baliseimage]http://www.unautresite.com/photos/img-3.jpg[/baliseimage] et c\'est fini !';
  2.  
  3. function resize($masque){
  4. $taille = @getimagesize($masque[2]);
  5. $max=100;//largeur max autorisée en pixels
  6. $haut_i = $taille[1];
  7. $larg_i = $taille[0];
  8. if($larg_i ›$max)
  9. {
  10. $coeff=$max/$larg_i;
  11. $larg_i=$max;
  12. $haut_i=ceil($haut_i*$coeff);
  13. }
  14. return $masque[1].'‹img src="'.$masque[2].'" height="'.$haut_i.'" width="'.$larg_i.'"›'.$masque[3];
  15. }
  16.  
  17. $texte=preg_replace_callback('`(.*?)\[baliseimage](.*?)\[/baliseimage](.*?)`s',resize,$texte);
  18.  
  19. echo $texte;


Avatar :: Amandine Un article de AmandineModifié 4 fois. (dernière modification le 09/04/2005 12:49:47 par Amandine)



Source : www.expreg.com


Commenter l'article

Commentaires


12/04/2005 22:08:32 : ???

Heu Amandine tu nous fais quoi?????????

- Adenine -

Sélection, tri et recherche d'articles
FILTRER :
TRIER :1er critère : 2e critère :
CHERCHER : Dans les titres Dans le contenu


[Afficher les liens en fonction des critères du formulaire ci-dessus]

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 13/09/2004, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/ast-rf-229.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.