Joomla! Programmierung/Framework/JHtml/image

Aus Joomla! Dokumentation
Wechseln zu: Navigation, Suche

Gibt ein <img></img> Element aus.

Inhaltsverzeichnis

[Bearbeiten] Syntax

static string image( $url, $alt, $attribs )

  • @since Joomla 1.5
Parameter Datentyp Beschreibung Standardwert
$url string Die URL, zum Bild
$alt string Der "alt"-Text des Bildes.
$attribs array() Attribute des <image/>, müssen als Array in der Form array('name' => 'wert') übergeben werden. null

[Bearbeiten] Beispiele

[Bearbeiten] Bild ausgeben

$url = 'http://cdn.joomla.org/images/logo.png';
$alt = 'Joomla! Logo';
$attribs['width'] = '235px';
$attribs['height'] = '46px';
 
echo JHtml::_('image', $url, $alt, $attribs);

Ausgabe:

<img src="http://cdn.joomla.org/images/logo.png" alt="Joomla! Logo" width="235px" height="46px" />

[Bearbeiten] Siehe auch

[Bearbeiten] Quellcode

JHtml::image in Joomla! 2.5.4

Folder blue.png libraries

  • Folder red.png joomla
    • Folder green.png html
      • File php.png html.php
  1. public static function image($file, $alt, $attribs = null, $relative = false, $path_only = false)
  2. {
  3. if (is_array($attribs))
  4. {
  5. $attribs = JArrayHelper::toString($attribs);
  6. }
  7.  
  8. $includes = self::includeRelativeFiles('images', $file, $relative, false, false);
  9.  
  10. // If only path is required
  11. if ($path_only)
  12. {
  13. if (count($includes))
  14. {
  15. return $includes[0];
  16. }
  17. else
  18. {
  19. return null;
  20. }
  21. }
  22. else
  23. {
  24. return '<img src="' . (count($includes) ? $includes[0] : '') . '" alt="' . $alt . '" ' . $attribs . ' />';
  25. }
  26. }
Meine Werkzeuge
Namensräume
Varianten
Aktionen
Navigation
Sonstiges
Team Navigation
Werkzeuge