public static showImage ( string $path, string $image, string $title = '', string $url = null, integer $width = null, integer $height = null ) : string | ||
$path | string | The path to the image. |
$image | string | The filename of the image. |
$title | string | The title (will be used as alt). |
$url | string | The url |
$width | integer | The width for the |
$height | integer | The height for the |
리턴 | string |
public static function showImage($path, $image, $title = '', $url = null, $width = null, $height = null)
{
$path = (string) $path;
$image = (string) $image;
$title = (string) $title;
$html = '<img src="' . $path . '/' . $image . '" alt="' . $title . '"';
if ($width) {
$html .= ' width="' . $width . '"';
}
if ($height) {
$html .= ' height="' . $height . '"';
}
$html .= ' />';
if ($url) {
$html = '<a href="' . $url . '" title="' . $title . '">' . $html . '</a>';
}
return $html;
}
public function test_showImage() { $path = '/src/Frontend/Files/Media/Backend/01'; $imageName = 'image-01.jpg'; $title = 'cowboy henk'; $url = 'http://www.test.com/private/nl/edit?id=1'; $width = 100; $height = 100; self::assertEquals('<a href="' . $url . '" title="' . $title . '"><img src="' . $path . '/' . $imageName . '" alt="' . $title . '" width="' . $width . '" height="' . $height . '" /></a>', DataGridFunctions::showImage($path, $imageName, $title, $url, $width, $height)); self::assertEquals('<img src="' . $path . '/' . $imageName . '" alt="' . $title . '" />', DataGridFunctions::showImage($path, $imageName, $title)); }