From: Stephen Cameron Date: Wed, 9 Oct 2019 17:01:28 +0000 (+0200) Subject: Large image popups + better image handling for products. WIP #3074 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=291084f51aba40bd30aa5c8dafbb00a75b600b11;p=pmi.git Large image popups + better image handling for products. WIP #3074 --- diff --git a/app/Models/Product.php b/app/Models/Product.php index 606eb69..54fce9b 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -8,6 +8,7 @@ use Cubist\Util\Json; use Illuminate\Support\Facades\App; use Illuminate\Support\Str; use Spatie\MediaLibrary\Models\Media; +use Spatie\Image\Manipulations; class Product extends CubistMagicPageModel { @@ -144,6 +145,20 @@ class Product extends CubistMagicPageModel $this->addSpecifications(); } + // Image handling + public function registerMediaConversions(Media $media = null) { + + parent::registerMediaConversions($media); + + $this->addMediaConversion('thumb') + ->width(300) + ->height(300); + + $this->addMediaConversion('large') + ->fit(Manipulations::FIT_MAX, 1200, 1000); // Don't enlarge small images + } + + protected static function _getRelatedEntities() { if (null === self::$_specifications) { @@ -345,7 +360,7 @@ class Product extends CubistMagicPageModel { if ($this->images) { - $image = $this->getFirstMediaUrl($this->images); + $image = $this->getFirstMediaUrl($this->images, 'thumb'); if ($image) { return $image; diff --git a/package.json b/package.json index 3a73abb..41c7aa6 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "tippy.js": "^4.3.5", "unorm": "^1.6.0", "vue": "^2.6.10", + "vue-gallery": "^2.0.0", "vue-slide-up-down": "^1.7.2", "vue-slider-component": "^3.0.40", "vue-template-compiler": "^2.6.10" diff --git a/public/images/vendor/blueimp-gallery/error.png b/public/images/vendor/blueimp-gallery/error.png new file mode 100644 index 0000000..a5577c3 Binary files /dev/null and b/public/images/vendor/blueimp-gallery/error.png differ diff --git a/public/images/vendor/blueimp-gallery/error.svg b/public/images/vendor/blueimp-gallery/error.svg new file mode 100644 index 0000000..184206a --- /dev/null +++ b/public/images/vendor/blueimp-gallery/error.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/public/images/vendor/blueimp-gallery/loading.gif b/public/images/vendor/blueimp-gallery/loading.gif new file mode 100644 index 0000000..90f28cb Binary files /dev/null and b/public/images/vendor/blueimp-gallery/loading.gif differ diff --git a/public/images/vendor/blueimp-gallery/play-pause.png b/public/images/vendor/blueimp-gallery/play-pause.png new file mode 100644 index 0000000..ece6cfb Binary files /dev/null and b/public/images/vendor/blueimp-gallery/play-pause.png differ diff --git a/public/images/vendor/blueimp-gallery/play-pause.svg b/public/images/vendor/blueimp-gallery/play-pause.svg new file mode 100644 index 0000000..a7f1f50 --- /dev/null +++ b/public/images/vendor/blueimp-gallery/play-pause.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/public/images/vendor/blueimp-gallery/video-play.png b/public/images/vendor/blueimp-gallery/video-play.png new file mode 100644 index 0000000..353e3a5 Binary files /dev/null and b/public/images/vendor/blueimp-gallery/video-play.png differ diff --git a/public/images/vendor/blueimp-gallery/video-play.svg b/public/images/vendor/blueimp-gallery/video-play.svg new file mode 100644 index 0000000..b5ea206 --- /dev/null +++ b/public/images/vendor/blueimp-gallery/video-play.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/js/components/ProductGallery.vue b/resources/js/components/ProductGallery.vue index 6733217..3fc2570 100644 --- a/resources/js/components/ProductGallery.vue +++ b/resources/js/components/ProductGallery.vue @@ -1,32 +1,51 @@