diff --git a/config/rapidez/statamic.php b/config/rapidez/statamic.php index 1be3019..1b32c03 100644 --- a/config/rapidez/statamic.php +++ b/config/rapidez/statamic.php @@ -33,6 +33,10 @@ ], ], + // This defines the multiplier for the responsive images and which size to show. + // Default is 1.5x the displayed size. + 'responsive_image_multiplier' => 150, + 'runway' => [ // Should we configure Runway? You'll get a products, // categories and brands / manufacturers resource. diff --git a/resources/views/stack/head.blade.php b/resources/views/stack/head.blade.php new file mode 100644 index 0000000..39c5163 --- /dev/null +++ b/resources/views/stack/head.blade.php @@ -0,0 +1,11 @@ + diff --git a/resources/views/vendor/responsive-images/responsiveImage.blade.php b/resources/views/vendor/responsive-images/responsiveImage.blade.php new file mode 100644 index 0000000..3fd9313 --- /dev/null +++ b/resources/views/vendor/responsive-images/responsiveImage.blade.php @@ -0,0 +1,35 @@ + + @foreach (($breakpoints ?? []) as $breakpoint) + @foreach($breakpoint->sources() ?? [] as $source) + @php + $srcSet = $source->getSrcset(); + @endphp + + @if($srcSet !== null) + getMimeType()) type="{{ $type }}" @endif + @if($media = $source->getMediaString()) media="{{ $media }}" @endif + srcset="{{ $srcSet }}" + @if($includePlaceholder ?? false) sizes="1px" @endif + > + @endif + @endforeach + @endforeach + + {{ $asset['alt'] ?? $asset['title'] }} + diff --git a/src/RapidezStatamicServiceProvider.php b/src/RapidezStatamicServiceProvider.php index 24a2006..c12d158 100644 --- a/src/RapidezStatamicServiceProvider.php +++ b/src/RapidezStatamicServiceProvider.php @@ -47,7 +47,8 @@ public function boot() ->bootRunway() ->bootComposers() ->bootPublishables() - ->bootUtilities(); + ->bootUtilities() + ->bootStack(); Vue::register(); Alternates::register(); @@ -83,6 +84,7 @@ public function bootRoutes() : self public function bootViews() : self { $this->loadViewsFrom(__DIR__.'/../resources/views', 'rapidez-statamic'); + $this->loadViewsFrom(__DIR__.'/../resources/views/vendor/responsive-images', 'responsive-images'); return $this; } @@ -199,10 +201,17 @@ public function bootUtilities() : static ->name('import-brands'); }); }); - + return $this; } - + + public function bootStack() : static + { + View::startPush('head', view('rapidez-statamic::stack.head')); + + return $this; + } + public function currentSiteIsEnabled(): bool { return !config('statamic.sites.sites.' . Site::current()->handle() . '.attributes.disabled', false);