1 | <?php |
||
25 | class GlLazyLoadImg |
||
26 | { |
||
27 | const BLANK = 0; |
||
28 | const LOSSY = 1; |
||
29 | |||
30 | /** |
||
31 | * @var string rootpath |
||
32 | */ |
||
33 | private $rootpath; |
||
34 | |||
35 | /** |
||
36 | * @var int |
||
37 | */ |
||
38 | private $type; |
||
39 | |||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $moveToAttribute; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | private $excludeAttributesList; |
||
50 | |||
51 | /** |
||
52 | * constructor - set root directory to relative url |
||
53 | * |
||
54 | * @param string $rootpath |
||
55 | * @param int $type |
||
56 | * @param string $moveToAttribute |
||
57 | * @param array $excludeAttributesList |
||
58 | */ |
||
59 | public function __construct( |
||
70 | |||
71 | /** |
||
72 | * create lossy gif image and encode to data uri format |
||
73 | * minimal size is jpeg |
||
74 | * |
||
75 | * @param $src resource GD library |
||
76 | * @param int $minwidth min width in pixels (height autocalculte) |
||
77 | * |
||
78 | * @return string data uri format |
||
79 | */ |
||
80 | public function getLossyGifDataURI($src, $minwidth = 75) |
||
97 | |||
98 | /** |
||
99 | * create blank image with same size in data uri format |
||
100 | * minimal size is gif |
||
101 | * |
||
102 | * @param int $red red component background color (default 255) |
||
103 | * @param int $green green component background color (default 255) |
||
104 | * @param int $blue blue component background color (default 255) |
||
105 | * |
||
106 | * @return string data uri format |
||
107 | */ |
||
108 | public function get1x1GifDataURI($red = 255, $green = 255, $blue = 255) |
||
127 | |||
128 | |||
129 | /** |
||
130 | * find type of image and open it |
||
131 | * |
||
132 | * @param string $file |
||
133 | * |
||
134 | * @return bool|resource |
||
135 | */ |
||
136 | private function openImage($file) |
||
160 | |||
161 | /** |
||
162 | * replace all src attributes from img tags with datauri and set another attribute with old src value |
||
163 | * support jpeg, png or gif file format |
||
164 | * |
||
165 | * @param string $html |
||
166 | * |
||
167 | * @throws \Exception |
||
168 | * @return string |
||
169 | */ |
||
170 | public function autoDataURI($html) |
||
204 | } |
||
205 |