add watermark on zoom, update display of article nature on shelve (change icon to text

This commit is contained in:
ludo
2024-02-04 22:09:53 +01:00
parent 4c6f9b3b61
commit 308b6cb349
9 changed files with 93 additions and 58 deletions

View File

@@ -16,8 +16,6 @@ class CategoryController extends Controller
$tags = $request->input('tags') ?? [];
$data = Shelves::getOffersByCategoryAndNature($categoryId, $articleNatureId, $tags, $articleNature, $displayByRows);
// dump($data);
// exit;
return view('Shop.Shelves.shelve', $data);
}

View File

@@ -103,6 +103,11 @@ class Medias
return self::getSrcByType($image, 'normal');
}
public static function getZoomSrc($image)
{
return self::getSrcByType($image, 'zoom');
}
public static function getSrcByType($image, $type)
{
return $image ? '/storage/'.$image['id'].'/conversions/'.self::getFilename($image, $type) : false;

View File

@@ -81,7 +81,7 @@ class Articles
$images = ArticleImages::getFullImagesByArticle($article);
$data['image'] = self::getPreviewSrc($images[0] ?? false);
$data['images'] = count($images) ? $images : false;
$data['image_big'] = self::getImageSrc($images[0] ?? false);
$data['image_big'] = self::getZoomSrc($images[0] ?? false);
$data['inherited'] = ArticleInherited::getInherited($id);
$data['categories'] = ArticleCategories::getCategoriesNameByArticle($article);
$data['tags'] = ArticleTags::getFullTagsSlugByArticle($article);
@@ -143,7 +143,7 @@ class Articles
public static function getArticlesToSell($options)
{
$articles = self::getArticlesWithOffers($options);
$searchOrder = array_flip($options['ids']->toArray() ?? []);
$searchOrder = $options['ids'] ?? false ? array_flip($options['ids']->toArray()) : false;
foreach ($articles as $article) {
$price_lists = $article->offers[0]->tariff->price_lists->toArray();
if (! count($price_lists)) {
@@ -151,7 +151,9 @@ class Articles
}
if (! is_array($data[$article->name] ?? false)) {
$data[$article->name] = self::getDataForSale($article);
$data[$article->name]['searchOrder'] = $searchOrder[$article->id];
if ($searchOrder) {
$data[$article->name]['searchOrder'] = $searchOrder[$article->id];
}
}
$prices = $price_lists[0]['price_list_values'][0];
$article_nature_name = strtolower($article->article_nature->name);

View File

@@ -7,7 +7,7 @@ class Shelves
public static function getOffersByCategoryAndNature($categoryId, $articleNatureId = false, $tags = [], $articleNature = false, $displayByRows = false)
{
$articleNatures = Articles::getArticleNaturesWithOffers(['category_id' => $categoryId]);
$productType = self::getProductType($articleNature, $articleNatures);
$productType = self::getProductType($articleNatureId, $articleNature, $articleNatures);
$articleNatureId = $articleNatureId ?
$articleNatureId :
self::getArticleNatureId($articleNature, $articleNatures);

View File

@@ -44,6 +44,12 @@ trait Imageable
->watermarkHeight(100, Manipulations::UNIT_PERCENT)
->watermarkWidth(100, Manipulations::UNIT_PERCENT)
->watermarkFit(Manipulations::FIT_FILL);
$this->addMediaConversion('zoom')->fit(Manipulations::FIT_CROP, 1200, 1200)
->watermark($watermark)
->watermarkHeight(100, Manipulations::UNIT_PERCENT)
->watermarkWidth(100, Manipulations::UNIT_PERCENT)
->watermarkFit(Manipulations::FIT_FILL);
// $this->addMediaConversion('zoom')->fit(Manipulations::FIT_CROP, 1200, 1200)->withResponsiveImages();
}
}

View File

@@ -16,52 +16,57 @@ trait Imageable
return Medias::getImages(self::get($id));
}
public static function getThumb($image, $with_undefined = true)
public static function getThumb($image, $undefined = true)
{
$src = self::getThumbSrc($image, $with_undefined);
$src = self::getThumbSrc($image, $undefined);
return $src ? "<img src='{$src}'>" : '';
}
public static function getThumbSrc($image, $with_undefined = true)
public static function getThumbSrc($image, $undefined = true)
{
return $image ? Medias::getThumbSrc($image) : ($with_undefined ? '/img/visuel-non-disponible.jpg' : '');
return $image ? Medias::getThumbSrc($image) : ($undefined ? '/img/visuel-non-disponible.jpg' : '');
}
public static function getPreview($image, $with_undefined = true)
public static function getPreview($image, $undefined = true)
{
$src = self::getPreviewSrc($image, $with_undefined);
$src = self::getPreviewSrc($image, $undefined);
return $src ? "<img src='{$src}' class='img-fluid'>" : '';
}
public static function getPreviewSrc($image, $with_undefined = true)
public static function getPreviewSrc($image, $undefined = true)
{
return $image ? Medias::getPreviewSrc($image) : ($with_undefined ? self::getUnknown() : '');
return $image ? Medias::getPreviewSrc($image) : ($undefined ? self::getUnknown() : '');
}
public static function getNormal($image, $with_undefined = true)
public static function getNormal($image, $undefined = true)
{
$src = self::getNormalSrc($image, $with_undefined);
$src = self::getNormalSrc($image, $undefined);
return $src ? "<img src='{$src}'>" : '';
}
public static function getNormalSrc($image, $with_undefined = true)
public static function getNormalSrc($image, $undefined = true)
{
return $image ? Medias::getNormalSrc($image) : ($with_undefined ? self::getUnknown() : '');
return $image ? Medias::getNormalSrc($image) : ($undefined ? self::getUnknown() : '');
}
public static function getImage($image, $with_undefined = true)
public static function getZoomSrc($image, $undefined = true)
{
$src = self::getImageSrc($image, $with_undefined);
return $image ? Medias::getZoomSrc($image) : ($undefined ? self::getUnknown() : '');
}
public static function getImage($image, $undefined = true)
{
$src = self::getImageSrc($image, $undefined);
return $src ? "<img src='{$src}' class='img-fluid'>" : '';
}
public static function getImageSrc($image, $with_undefined = true)
public static function getImageSrc($image, $undefined = true)
{
return $image ? Medias::getImageSrc($image) : ($with_undefined ? self::getUnknown() : '');
return $image ? Medias::getImageSrc($image) : ($undefined ? self::getUnknown() : '');
}
public static function getUnknown()

View File

@@ -305,6 +305,10 @@ div.megamenu ul.megamenu li.megamenu.level1
font-size: 0.8em
}
.sp-lightbox {
z-index: 1300;
}
@font-face {
font-family: 'noto_sanscondensed';

View File

@@ -1,26 +1,41 @@
@foreach ($article_natures as $nature)
<div class="btn products" data-id="{{ $nature }}">
@if ($article_nature == $nature)
<img src="{{ App\Repositories\Shop\ArticleNatures::getIconBySlug($nature, 'normal', 'icon_selection') }}">
@else
<img src="{{ App\Repositories\Shop\ArticleNatures::getIconBySlug($nature, 'normal', 'icon') }}">
@endif
</div>
<div class="btn products" data-id="{{ $nature }}">
@if ($article_nature == $nature)
@php
$iconType = 'icon_selection';
$iconClass = 'badge-success';
@endphp
@else
@php
$iconType = 'icon';
$iconClass = 'badge-secondary';
@endphp
@endif
@php
$icon = App\Repositories\Shop\ArticleNatures::getIconBySlug($nature, 'normal', $iconType);
@endphp
@if ($icon)
<img src="{{ $icon }}" alt="{{ $nature }}">
@else
<span class="badge {{ $iconClass }}" style="font-size: 1.2em;">{{ $nature }}</span>
@endif
</div>
@endforeach
@push('js')
<script>
$('#by_rows').click(function() {
$('#display_by_rows').val(1);
$('#category-form').submit();
});
$('#by_cards').click(function() {
$('#display_by_rows').val(0);
$('#category-form').submit();
});
$('.products').click(function() {
$('#article_nature').val($(this).data('id'));
$('#category-form').submit();
});
</script>
@endpush
<script>
$('#by_rows').click(function() {
$('#display_by_rows').val(1);
$('#category-form').submit();
});
$('#by_cards').click(function() {
$('#display_by_rows').val(0);
$('#category-form').submit();
});
$('.products').click(function() {
$('#article_nature').val($(this).data('id'));
$('#category-form').submit();
});
</script>
@endpush

View File

@@ -1,20 +1,20 @@
<div class="sp-loading"><img src="images/sp-loading.gif" alt=""><br>LOADING IMAGES</div>
<div class="sp-wrap" style="width: 100%;">
@if ($images)
@foreach ($images as $image)
<a href="{{ App\Repositories\Core\Images::getImageSrc($image) }}">
<img src="{{ App\Repositories\Core\Images::getNormalSrc($image) }}" class="img-fluid">
</a>
@endforeach
@else
<img src="{{ $image }}" class="img-fluid">
@endif
@if ($images)
@foreach ($images as $image)
<a href="{{ App\Repositories\Shop\Articles::getZoomSrc($image) }}">
<img src="{{ App\Repositories\Core\Images::getNormalSrc($image) }}" class="img-fluid">
</a>
@endforeach
@else
<img src="{{ $image }}" class="img-fluid">
@endif
</div>
@push('js')
<script>
$(window).load(function() {
$('.sp-wrap').smoothproducts();
});
</script>
<script>
$(window).load(function() {
$('.sp-wrap').smoothproducts();
});
</script>
@endpush