core-bundle/src/Resources/contao/library/Contao/Image.php
public static function getHtml($src, $alt='', $attributes='')
	{
		$src = static::getPath($src);

		if ($src == '')
		{
			return '';
		}

		$container = System::getContainer();
		$rootDir = $container->getParameter('kernel.project_dir');
		$webDir = StringUtil::stripRootDir($container->getParameter('contao.web_dir'));

		if (!is_file($rootDir . '/' . $src))
		{
			// Handle public bundle resources
			if (file_exists($rootDir . '/' . $webDir . '/' . $src))
			{
				$src = $webDir . '/' . $src;
			}
			else
			{
				return '';
			}
		}

		$objFile = new File($src);

		// Strip the web/ prefix (see #337)
		if (strncmp($src, $webDir . '/', \strlen($webDir) + 1) === 0)
		{
			$src = substr($src, \strlen($webDir) + 1);
		}

		$context = (strncmp($src, 'assets/', 7) === 0) ? 'assets_context' : 'files_context';

		return '<img src="' . Controller::addStaticUrlTo(System::urlEncode($src), $container->get('contao.assets.'.$context)) . '" width="' . $objFile->width . '" height="' . $objFile->height . '" alt="' . StringUtil::specialchars($alt) . '"' . (($attributes != '') ? ' ' . $attributes : '') . '>';
	}
public static function getHtml($src, $alt='', $attributes='')
	{
		$src = static::getPath($src);

		if ($src == '')
		{
			return '';
		}

		$container = System::getContainer();
		$rootDir = $container->getParameter('kernel.project_dir');
		$webDir = StringUtil::stripRootDir($container->getParameter('contao.web_dir'));

		if (!is_file($rootDir . '/' . $src))
		{
			// Handle public bundle resources
			if (file_exists($rootDir . '/' . $webDir . '/' . $src))
			{
				$src = $webDir . '/' . $src;
			}
			else
			{
				return '';
			}
		}

		$objFile = new File($src);

		// Strip the web/ prefix (see #337)
		if (strncmp($src, $webDir . '/', \strlen($webDir) + 1) === 0)
		{
			$src = substr($src, \strlen($webDir) + 1);
		}

		$context = (strncmp($src, 'assets/', 7) === 0) ? 'assets_context' : 'files_context';

		return '<img src="' . Controller::addStaticUrlTo(System::urlEncode($src), $container->get('contao.assets.'.$context)) . '" width="' . $objFile->width . '" height="' . $objFile->height . '" alt="' . StringUtil::specialchars($alt) . '"' . (($attributes != '') ? ' ' . $attributes : '') . '>';
	}
public static function getHtml ( $ src , $ alt = '' , $ attributes = '' ) { $ src = static :: getPath ( $ src ) ; if ( $ src == '' ) { return '' ; } $ container = System :: getContainer ( ) ; $ rootDir = $ container -> getParameter ( 'kernel.project_dir' ) ; $ webDir = StringUtil :: stripRootDir ( $ container -> getParameter ( 'contao.web_dir' ) ) ; if ( ! is_file ( $ rootDir . '/' . $ src ) ) { // Handle public bundle resources if ( file_exists ( $ rootDir . '/' . $ webDir . '/' . $ src ) ) { $ src = $ webDir . '/' . $ src ; } else { return '' ; } } $ objFile = new File ( $ src ) ; // Strip the web/ prefix (see #337) if ( strncmp ( $ src , $ webDir . '/' , \ strlen ( $ webDir ) + 1 ) === 0 ) { $ src = substr ( $ src , \ strlen ( $ webDir ) + 1 ) ; } $ context = ( strncmp ( $ src , 'assets/' , 7 ) === 0 ) ? 'assets_context' : 'files_context' ; return '<img src="' . Controller :: addStaticUrlTo ( System :: urlEncode ( $ src ) , $ container -> get ( 'contao.assets.' . $ context ) ) . '" width="' . $ objFile -> width . '" height="' . $ objFile -> height . '" alt="' . StringUtil :: specialchars ( $ alt ) . '"' . ( ( $ attributes != '' ) ? ' ' . $ attributes : '' ) . '>' ; }
Generate an image tag and return it as string

@param string $src        The image path
@param string $alt        An optional alt attribute
@param string $attributes A string of other attributes

@return string The image HTML tag
Generate an image tag and return it as string