From: Vincent Vanwaelscappel Date: Fri, 20 Mar 2020 13:01:31 +0000 (+0100) Subject: wip #3511 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a87d03886be98d80967447e03745defff8e67410;p=pmi.git wip #3511 @1 --- diff --git a/app/Models/Product.php b/app/Models/Product.php index 87d9587..3f31f3b 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -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() { diff --git a/resources/styles/common/global.styl b/resources/styles/common/global.styl index d85c341..a8cc346 100644 --- a/resources/styles/common/global.styl +++ b/resources/styles/common/global.styl @@ -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 diff --git a/resources/styles/components/products.styl b/resources/styles/components/products.styl index 469eb10..6c1eb43 100644 --- a/resources/styles/components/products.styl +++ b/resources/styles/components/products.styl @@ -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 @@ -49,8 +53,20 @@ @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 + } diff --git a/resources/views/pages/home.blade.php b/resources/views/pages/home.blade.php index f79d407..a77ad3c 100644 --- a/resources/views/pages/home.blade.php +++ b/resources/views/pages/home.blade.php @@ -105,8 +105,11 @@ @foreach ($page->get('solutions', []) as $solution) - + + {{ $page->getImageAltbyCollection($solution['image'],$solution['title']) }} + {{ $solution['title'] }} @endforeach diff --git a/resources/views/partials/home-products.blade.php b/resources/views/partials/home-products.blade.php index 88e08f3..f1d8679 100644 --- a/resources/views/partials/home-products.blade.php +++ b/resources/views/partials/home-products.blade.php @@ -3,8 +3,10 @@ href="{{ $nav->getHrefById('product_type/'.$highlight['link']) }}">
{{-- Proportional image holder --}} -
+
+ {{$page->getImageAltByCollection($highlight['image'],$highlight['title'])}} +

{{ $highlight['title'] }}

diff --git a/resources/views/partials/product-link.blade.php b/resources/views/partials/product-link.blade.php index d89269d..3f6bead 100644 --- a/resources/views/partials/product-link.blade.php +++ b/resources/views/partials/product-link.blade.php @@ -5,8 +5,10 @@ {{-- Image holder --}}
-
+
+ {{$product->getEntity()->image_alt}} +
diff --git a/webpack.mix.js b/webpack.mix.js index a6d6bca..b410481 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -19,6 +19,7 @@ mix.webpackConfig({ 'css/cssgrid', 'css/flexbox', 'css/flexboxtweener', + 'css/objectfit', ] }), ],