PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / vendor / league / glide / src / Manipulators / Helpers / Dimension.php

Dimension.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.3, at vendor/league/glide/src/Manipulators/Helpers/Dimension.php

57 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace League\Glide\Manipulators\Helpers;
4
5 use Intervention\Image\Image;
6
7 class Dimension
8 {
9 /**
10 * The source image.
11 *
12 * @var Image
13 */
14 protected $image;
15
16 /**
17 * The device pixel ratio.
18 *
19 * @var float
20 */
21 protected $dpr;
22
23 /**
24 * Create dimension helper instance.
25 *
26 * @param Image $image The source image.
27 * @param float $dpr The device pixel ratio.
28 */
29 public function __construct(Image $image, $dpr = 1)
30 {
31 $this->image = $image;
32 $this->dpr = $dpr;
33 }
34
35 /**
36 * Resolve the dimension.
37 *
38 * @param string $value The dimension value.
39 *
40 * @return float|null The resolved dimension.
41 */
42 public function get($value)
43 {
44 if (is_numeric($value) and $value > 0) {
45 return (float) $value * $this->dpr;
46 }
47
48 if (preg_match('/^(\d{1,2}(?!\d)|100)(w|h)$/', $value, $matches)) {
49 if ('h' === $matches[2]) {
50 return (float) $this->image->height() * ((float) $matches[1] / 100);
51 }
52
53 return (float) $this->image->width() * ((float) $matches[1] / 100);
54 }
55 }
56 }
57