]> _ Git - pmi.git/commitdiff
wip #3511 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 20 Mar 2020 13:01:31 +0000 (14:01 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 20 Mar 2020 13:01:31 +0000 (14:01 +0100)
app/Models/Product.php
resources/styles/common/global.styl
resources/styles/components/products.styl
resources/views/pages/home.blade.php
resources/views/partials/home-products.blade.php
resources/views/partials/product-link.blade.php
webpack.mix.js

index 87d95878b0114c21f38000376696a64ee40637dd..3f31f3b817e6f2bb5373df202be0ad9fb2d1e3b5 100644 (file)
@@ -391,6 +391,20 @@ class Product extends CubistMagicPageModel
         return $this->image_fallback;
     }
 
+    public function getImageAltAttribute()
+    {
+        if ($this->images) {
+
+            $image = $this->getFirstMediaAlt($this->images, '');
+
+            if ($image) {
+                return $image;
+            }
+        }
+
+        return $this->reference . ' - ' . $this->name;
+    }
+
 
     public function getSearchShortTitle()
     {
index d85c3410ad8bbdc73f06114738463a76716221a4..a8cc346ad789ba01a65bafd328caf53c5c09b259 100644 (file)
@@ -15,6 +15,18 @@ p:not(:last-child)
   horizontal-spacing($horizontal-gutter)
   width: 100%
 
+.bgimg
+  width 100%
+  height 100%
+  display inline
+  object-fit contain
+  object-position 50% 50%
+
+  .no-objectfit & {
+    height auto
+  }
+
+
 // Overlapping content
 $overlap-amount = 10vw
 
index 469eb10ab98a0f13214725573e0eb767198c2a85..6c1eb4347e0e81dcb4f4bc1b10bf84487e3c3415 100644 (file)
@@ -1,6 +1,7 @@
 .products
 
   // Grid view of products
+
   &-grid
     // When in auto grid mode, make the minimum width a bit
     // larger so we end up with 3 cols at the largest size.
@@ -25,6 +26,7 @@
     .links
       white-space nowrap;
       font-size 14px
+
       .link
         width 50%
         white-space nowrap
@@ -38,7 +40,9 @@
       overflow: hidden
 
       li
-        margin-bottom: 0 // avoids last line being partially cropped
+        margin-bottom: 0
+
+    // avoids last line being partially cropped
 
     h3
       height: 21px
   @apply bg-white relative pb-100p
 
   .product-img
-    @apply absolute bg-contain bg-center bg-no-repeat
+    @apply absolute
+
     width: 70%
     height: 70%
     top: 15%
     left: 15%
+
+    img
+      width 100%
+      height 100%
+      display inline
+      object-fit contain
+      object-position 50% 50%
+
+      .no-objectfit & {
+        height auto
+      }
index f79d4078aa65019fe19ad7773cca2fe8db739c3b..a77ad3c42058e99af7a2ee6d71db95616b123381 100644 (file)
                 @foreach ($page->get('solutions', []) as $solution)
                     <a class="solutions-link" href="{{ $nav->getHrefByID($solution['page']) }}">
                         <div class="solutions-link-sizer"></div>
-                        <span class="solutions-link-bg"
-                              style="background-image:url({{ $page->getImageURLbyCollection($solution['image']) }})"></span>
+                        <span class="solutions-link-bg">
+                            <img src="{{ $page->getImageURLbyCollection($solution['image']) }}"
+                                 alt="{{ $page->getImageAltbyCollection($solution['image'],$solution['title']) }}"
+                                 class="bgimg"/>
+                        </span>
                         <span class="solutions-link-text">{{ $solution['title'] }}</span>
                     </a>
                 @endforeach
index 88e08f35342b7596aea6f2a56932369fb42b216a..f1d867955a8a8f07e298a771f6414e4f394a5a48 100644 (file)
@@ -3,8 +3,10 @@
        href="{{ $nav->getHrefById('product_type/'.$highlight['link']) }}">
         <div class="flex items-center justify-center flex-grow">
             {{-- Proportional image holder --}}
-            <div class="mb-4 bg-contain bg-no-repeat bg-center w-full"
-                 style="padding-bottom: 62%; background-image: url({{ $page->getImageUrlByCollection($highlight['image']) }})"></div>
+            <div class="mb-4 bg-contain bg-no-repeat bg-center w-full">
+                <img src="{{ $page->getImageUrlByCollection($highlight['image']) }}"
+                     alt="{{$page->getImageAltByCollection($highlight['image'],$highlight['title'])}}" class="bgimg"/>
+            </div>
         </div>
         <p class="text-lg text-navy font-display font-medium">{{ $highlight['title'] }}</p>
     </a>
index d89269d4add4167613ff6be00134980636408d5e..3f6bead2a05f6983da21b72f4356732dba92783e 100644 (file)
@@ -5,8 +5,10 @@
     {{-- Image holder --}}
     <a href="{{ $product->getEntity()->URL }}">
         <div class="product-img-holder">
-            <div class="product-img"
-                 style="background-image: url({{ $product->getEntity()->image }})"></div>
+            <div class="product-img">
+                <img src="{{$product->getEntity()->image}}"
+                     alt="{{$product->getEntity()->image_alt}}"/>
+            </div>
         </div>
     </a>
 
index a6d6bcab67d0cd764b08e5502fa9bdbb399ae005..b410481204662bd6f77a2d59d4dea30b53651690 100644 (file)
@@ -19,6 +19,7 @@ mix.webpackConfig({
                 'css/cssgrid',
                 'css/flexbox',
                 'css/flexboxtweener',
+                'css/objectfit',
             ]
         }),
     ],