|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the bootstrap-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Bundle\BootstrapBundle\Twig\Extension\CSS; |
|
13
|
|
|
|
|
14
|
|
|
use WBW\Bundle\BootstrapBundle\Twig\Extension\AbstractTwigExtension; |
|
15
|
|
|
use WBW\Library\Core\Argument\Helper\StringHelper; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Abstract image Twig extension. |
|
19
|
|
|
* |
|
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
21
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\CSS |
|
22
|
|
|
* @abstract |
|
23
|
|
|
*/ |
|
24
|
|
|
abstract class AbstractImageTwigExtension extends AbstractTwigExtension { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Displays a Bootstrap image. |
|
28
|
|
|
* |
|
29
|
|
|
* @param string|null $src The source |
|
30
|
|
|
* @param string|null $alt The alternative text. |
|
31
|
|
|
* @param string|null $width The width. |
|
32
|
|
|
* @param string|null $height The height. |
|
33
|
|
|
* @param string|null $class The class. |
|
34
|
|
|
* @param string|null $useMap The use map. |
|
35
|
|
|
* @return string Returns the Bootstrap image. |
|
36
|
|
|
*/ |
|
37
|
|
|
protected function bootstrapImage(?string $src, ?string $alt, ?string $width, ?string $height, ?string $class, ?string $useMap): string { |
|
38
|
|
|
|
|
39
|
|
|
$template = "<img %attributes%/>"; |
|
40
|
|
|
|
|
41
|
|
|
$attributes = []; |
|
42
|
|
|
|
|
43
|
|
|
$attributes["src"] = $src; |
|
44
|
|
|
$attributes["alt"] = $alt; |
|
45
|
|
|
$attributes["width"] = $width; |
|
46
|
|
|
$attributes["height"] = $height; |
|
47
|
|
|
$attributes["class"] = $class; |
|
48
|
|
|
$attributes["usemap"] = $useMap; |
|
49
|
|
|
|
|
50
|
|
|
return str_replace(["%attributes%"], [StringHelper::parseArray($attributes)], $template); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|