Skip to content

Commit 0bbf1f0

Browse files
committed
Merge branch 'release2.8.0'
2 parents a4e2d90 + 31e9a1a commit 0bbf1f0

25 files changed

+916
-219
lines changed

.idea/codestream.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/laravel-storyblok.iml

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

+7-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.lando.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: laravel-storyblok
2+
recipe: laravel
3+
config:
4+
webroot: .
5+
php: '8.0'

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
}
2020
],
2121
"require": {
22-
"php": "^7.1|^8.0",
22+
"php": "^7.4|^8.0",
2323
"ext-json": "*",
2424
"barryvdh/reflection-docblock": "^2.0",
2525
"embed/embed": "^3.4",
2626
"illuminate/support": "^6.0|^7.0|^8.0",
27-
"ivopetkov/html5-dom-document-php": "2.*",
27+
"imgix/imgix-php": "^3.3",
28+
"ivopetkov/html5-dom-document-php": "2.*",
2829
"league/commonmark": "^2.0",
2930
"mundschenk-at/php-typography": "^6.5",
3031
"spatie/schema-org": "^3.3",
@@ -49,15 +50,14 @@
4950
"scripts": {
5051
"test": "vendor/bin/phpunit",
5152
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
52-
5353
},
5454
"config": {
5555
"sort-packages": true
5656
},
5757
"extra": {
5858
"laravel": {
5959
"providers": [
60-
"Riclep\\Storyblok\\StoryblokServiceProvider"
60+
"Riclep\\Storyblok\\StoryblokServiceProvider"
6161
],
6262
"aliases": {
6363
"Storyblok": "Riclep\\Storyblok\\StoryblokFacade"

config/storyblok.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,17 @@
139139
| Can be customized to proxy image service requests over a custom domain
140140
|
141141
*/
142-
'image_service_domain' => env('STORYBLOK_IMAGE_SERVICE_DOMAIN', 'img2.storyblok.com'),
142+
'image_service_domain' => env('STORYBLOK_IMAGE_SERVICE_DOMAIN', 'a.storyblok.com'),
143+
144+
/*
145+
|--------------------------------------------------------------------------
146+
| Image transformation driver
147+
|--------------------------------------------------------------------------
148+
|
149+
| The class used for transforming images Fields / image URLs
150+
|
151+
*/
152+
'image_transformer' => \Riclep\Storyblok\Support\ImageTransformers\Storyblok::class,
143153

144154
/*
145155
|--------------------------------------------------------------------------
@@ -149,7 +159,7 @@
149159
| This turns on live preview of changes in the editor if correctly set up
150160
|
151161
*/
152-
'live-preview' => true,
162+
'live_preview' => true,
153163

154164
/*
155165
|--------------------------------------------------------------------------
@@ -159,7 +169,5 @@
159169
| Class or ID selector for the HTML element wrapping your live preview content
160170
|
161171
*/
162-
'live-element' => '.storyblok-live',
163-
164-
172+
'live_element' => '.storyblok-live',
165173
];

phpunit.xml.dist

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
</testsuites>
1717
<filter>
1818
<whitelist>
19-
<directory suffix=".php">src/Fields</directory>
20-
<directory suffix=".php">src/Traits</directory>
19+
<directory suffix=".php">src/Fields</directory>
20+
<directory suffix=".php">src/Support</directory>
21+
<directory suffix=".php">src/Traits</directory>
2122
<file>src/Block.php</file>
2223
<file>src/Field.php</file>
2324
<file>src/FieldFactory.php</file>
2425
<file>src/Folder.php</file>
2526
<file>src/Page.php</file>
26-
<file>src/Support/ImageTransformation.php</file>
2727
</whitelist>
2828
</filter>
2929
<logging>

src/FieldFactory.php

+23-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111

1212
class FieldFactory
1313
{
14+
/**
15+
* Works out what class should be used for the given block’s content
16+
*
17+
* @param $block
18+
* @param $field
19+
* @param $key
20+
* @return \Illuminate\Support\Collection|mixed|Asset|Image|MultiAsset|RichText|Table
21+
*/
1422
public function build($block, $field, $key) {
1523
// does the Block assign any $_casts? This is key (field) => value (class)
1624
if (array_key_exists($key, $block->getCasts())) {
@@ -38,15 +46,23 @@ public function build($block, $field, $key) {
3846
return $this->arrayField($block, $field, $key);
3947
}
4048

41-
// legacy image fields
42-
if ($this->isLegacyImageField($field)) {
49+
// legacy and string image fields
50+
if ($this->isStringImageField($field)) {
4351
return new Image($field, $block);
4452
}
4553

4654
// strings or anything else - do nothing
4755
return $field;
4856
}
4957

58+
/**
59+
* If given an array field we need more processing to determine the class
60+
*
61+
* @param $block
62+
* @param $field
63+
* @param $key
64+
* @return \Illuminate\Support\Collection|mixed|Asset|Image|MultiAsset|RichText|Table
65+
*/
5066
public function arrayField($block, $field, $key) {
5167
// match link fields
5268
if (array_key_exists('linktype', $field)) {
@@ -63,8 +79,8 @@ public function arrayField($block, $field, $key) {
6379
// match asset fields - detecting raster images
6480
if (array_key_exists('fieldtype', $field) && $field['fieldtype'] === 'asset') {
6581

66-
// legacy image fields
67-
if($this->isLegacyImageField($field['filename'])) {
82+
// legacy and string image fields
83+
if($this->isStringImageField($field['filename'])) {
6884
return new Image($field, $block);
6985
}
7086

@@ -131,16 +147,15 @@ public function arrayField($block, $field, $key) {
131147
}
132148

133149

134-
135150
/**
136-
* Check if given string is an legacy image field
151+
* Check if given string is a string image field
137152
*
138153
* @param $filename
139154
* @return boolean
140155
*/
141-
public function isLegacyImageField($filename){
156+
public function isStringImageField($filename){
142157
$allowed_extentions = ['.jpg', '.jpeg', '.png', '.gif', '.webp'];
143158

144-
return is_string($filename) && Str::of( $filename )->lower()->endsWith( $allowed_extentions );
159+
return is_string($filename) && Str::of($filename)->lower()->endsWith($allowed_extentions);
145160
}
146161
}

0 commit comments

Comments
 (0)