PHPFusion\ImageRepo::getImage PHP Method

getImage() public static method

Get the imagepath or the html "img" tag
public static getImage ( string $image, string $alt = "", string $style = "", string $title = "", string $atts = "" ) : string
$image string The name of the image.
$alt string "alt" attribute of the image
$style string "style" attribute of the image
$title string "title" attribute of the image
$atts string Custom attributes of the image
return string The path of the image if the first argument is given, but others not. Otherwise the html "img" tag
    public static function getImage($image, $alt = "", $style = "", $title = "", $atts = "")
    {
        self::cache();
        $url = isset(self::$imagePaths[$image]) ? self::$imagePaths[$image] : IMAGES . "imagenotfound.jpg";
        if ($style) {
            $style = " style='{$style}'";
        }
        if ($title) {
            $title = " title='" . $title . "'";
        }
        return ($alt or $style or $title or $atts) ? "<img src='" . $url . "' alt='" . $alt . "'" . $style . $title . " " . $atts . " />" : $url;
    }

Usage Example

Ejemplo n.º 1
0
/**
 * Get the imagepath or the html "img" tag
 *
 * @param string $image The name of the image.
 * @param string $alt "alt" attribute of the image
 * @param string $style "style" attribute of the image
 * @param string $title "title" attribute of the image
 * @param string $atts Custom attributes of the image
 * @return string The path of the image if the first argument is given,
 * but others not. Otherwise the html "img" tag
 */
function get_image($image, $alt = "", $style = "", $title = "", $atts = "")
{
    return ImageRepo::getImage($image, $alt, $style, $title, $atts);
}