]> _ Git - fluidbook-v3.git/commitdiff
WIP #1406 @2
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 18 May 2017 14:47:51 +0000 (14:47 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 18 May 2017 14:47:51 +0000 (14:47 +0000)
framework/application/views/helpers/BackgroundBlock.php

index 8abf9ce9292ba321e4f4c821d99fd21f93200453..6924c3121ad39e5fdba425236905abcda10af31b 100644 (file)
@@ -25,9 +25,26 @@ class Fluidbook_View_Helper_BackgroundBlock extends CubeIT_View_Helper_Abstract
                                $image_ratio = $image_height / $image_width;\r
                                $attributes['data-bg-ratio'] = $image_ratio;\r
 \r
-                               $mobile = $this->imageProcess()->imageProcessGetURL($image_path, '', $image_width * 0.55, $image_height, array(), 'C', 'R', 'M');\r
+                               // Create a cropped version of the image for mobile that cuts off the left 45% of the image\r
+                // Make sure image is not wider than 900px when finished\r
+                $mobile_max_width = 900;\r
+                // Scale image, factoring in crop that will take place...\r
+                // Image will be cropped to 900px wide so ensure that we have 45% extra and then determine the target height\r
+                $target_height = ($mobile_max_width / 0.55) * $image_ratio;\r
+                //$mobile = $this->imageProcess()->imageProcessGetURL($image_path, '', $image_width * 0.55, $image_height, array(), 'C', 'R', 'M');\r
+                $mobile = $this->imageProcess()->imageProcessGetURL($image_path, '', $mobile_max_width, $target_height, array(), 'C', 'R', 'M');\r
 \r
-                               $bg = $this->htmlElement($this->picture(array(array('src' => $image_path, "width" => 1680), array("src" => $mobile, "width" => 1680, 'media' => '(max-width: 900px)'))), 'div', array('class' => 'picture'));\r
+                               $bg = $this->htmlElement($this->picture([\r
+                                   [\r
+                                       'src' => $image_path,\r
+                        'width' => 1680\r
+                    ],\r
+                    [\r
+                        'src' => $mobile,\r
+                        'width' => 900,\r
+                        'media' => '(max-width: 900px)'\r
+                    ]\r
+                ]), 'div', array('class' => 'picture'));\r
                                $content = $bg . $content;\r
                        }\r
                }\r