Merge branch 'develop' of github.com:getgrav/grav into feature/media

 Conflicts:
	CHANGELOG.md
This commit is contained in:
Matias Griese
2022-02-16 09:54:12 +02:00
8 changed files with 122 additions and 64 deletions

View File

@@ -4,6 +4,14 @@
2. [](#improved)
* By default, add media to only pages which have been initialized in pages loop
# v1.7.31
## mm/dd/2022
1. [](#new)
* Added support to get image size for SVG vector images [#3533](https://github.com/getgrav/grav/pull/3533)
2. [](#bugfix)
* Fixed `'mbstring' extension is not loaded` error, use Polyfill instead [#3504](https://github.com/getgrav/grav/pull/3504)
# v1.7.30
## 02/07/2022

View File

@@ -25,14 +25,10 @@ if (!file_exists(__DIR__ . '/../vendor/autoload.php')){
$autoload = require __DIR__ . '/../vendor/autoload.php';
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding.
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');

View File

@@ -25,14 +25,10 @@ if (!file_exists(__DIR__ . '/../vendor/autoload.php')){
$autoload = require __DIR__ . '/../vendor/autoload.php';
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding.
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');

View File

@@ -25,14 +25,10 @@ if (!file_exists(__DIR__ . '/../vendor/autoload.php')){
$autoload = require __DIR__ . '/../vendor/autoload.php';
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding.
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');

60
composer.lock generated
View File

@@ -840,22 +840,21 @@
},
{
"name": "itsgoingd/clockwork",
"version": "v5.1.4",
"version": "v5.1.5",
"source": {
"type": "git",
"url": "https://github.com/itsgoingd/clockwork.git",
"reference": "7252aa771b77ac8678b44290fd7ec7577435cce6"
"reference": "6a7b3942224fa53cf3704d9adba636e1f3dfeb9a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/itsgoingd/clockwork/zipball/7252aa771b77ac8678b44290fd7ec7577435cce6",
"reference": "7252aa771b77ac8678b44290fd7ec7577435cce6",
"url": "https://api.github.com/repos/itsgoingd/clockwork/zipball/6a7b3942224fa53cf3704d9adba636e1f3dfeb9a",
"reference": "6a7b3942224fa53cf3704d9adba636e1f3dfeb9a",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=5.6",
"psr/log": "1.* || ^2.0"
"php": ">=5.6"
},
"type": "library",
"extra": {
@@ -897,7 +896,7 @@
],
"support": {
"issues": "https://github.com/itsgoingd/clockwork/issues",
"source": "https://github.com/itsgoingd/clockwork/tree/v5.1.4"
"source": "https://github.com/itsgoingd/clockwork/tree/v5.1.5"
},
"funding": [
{
@@ -905,7 +904,7 @@
"type": "github"
}
],
"time": "2022-01-30T12:36:18+00:00"
"time": "2022-02-13T22:57:42+00:00"
},
{
"name": "league/climate",
@@ -1105,25 +1104,26 @@
},
{
"name": "maximebf/debugbar",
"version": "v1.17.3",
"version": "v1.18.0",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "e8ac3499af0ea5b440908e06cc0abe5898008b3c"
"reference": "0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/e8ac3499af0ea5b440908e06cc0abe5898008b3c",
"reference": "e8ac3499af0ea5b440908e06cc0abe5898008b3c",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6",
"reference": "0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6",
"shasum": ""
},
"require": {
"php": "^7.1|^8",
"psr/log": "^1|^2|^3",
"symfony/var-dumper": "^2.6|^3|^4|^5"
"symfony/var-dumper": "^2.6|^3|^4|^5|^6"
},
"require-dev": {
"phpunit/phpunit": "^7.5.20 || ^9.4.2"
"phpunit/phpunit": "^7.5.20 || ^9.4.2",
"twig/twig": "^1.38|^2.7|^3.0"
},
"suggest": {
"kriswallsmith/assetic": "The best way to manage assets",
@@ -1164,9 +1164,9 @@
],
"support": {
"issues": "https://github.com/maximebf/php-debugbar/issues",
"source": "https://github.com/maximebf/php-debugbar/tree/v1.17.3"
"source": "https://github.com/maximebf/php-debugbar/tree/v1.18.0"
},
"time": "2021-10-19T12:33:27+00:00"
"time": "2021-12-27T18:49:48+00:00"
},
{
"name": "miljar/php-exif",
@@ -2730,12 +2730,12 @@
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -4019,12 +4019,12 @@
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
},
"files": [
"src/functions_include.php"
]
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -5725,16 +5725,16 @@
},
{
"name": "sebastian/global-state",
"version": "5.0.3",
"version": "5.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49"
"reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2",
"shasum": ""
},
"require": {
@@ -5777,7 +5777,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3"
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5"
},
"funding": [
{
@@ -5785,7 +5785,7 @@
"type": "github"
}
],
"time": "2021-06-11T13:31:12+00:00"
"time": "2022-02-14T08:28:10+00:00"
},
{
"name": "sebastian/lines-of-code",

View File

@@ -20,16 +20,6 @@ if (PHP_SAPI === 'cli-server') {
}
}
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding.
if (!\extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');
// Ensure vendor libraries exist
$autoload = __DIR__ . '/vendor/autoload.php';
if (!is_file($autoload)) {
@@ -39,15 +29,18 @@ if (!is_file($autoload)) {
// Register the auto-loader.
$loader = require $autoload;
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding.
@ini_set('default_charset', 'UTF-8');
mb_internal_encoding('UTF-8');
use Grav\Common\Grav;
use RocketTheme\Toolbox\Event\Event;
// Get the Grav instance
$grav = Grav::instance(
array(
'loader' => $loader
)
);
$grav = Grav::instance(array('loader' => $loader));
// Process the page
try {

View File

@@ -159,8 +159,9 @@ class MediumFactory
return new ImageMedium($items, $blueprint);
case 'thumbnail':
return new ThumbnailImageMedium($items, $blueprint);
case 'animated':
case 'vector':
return new VectorImageMedium($items, $blueprint);
case 'animated':
return new StaticImageMedium($items, $blueprint);
case 'video':
return new VideoMedium($items, $blueprint);

View File

@@ -0,0 +1,68 @@
<?php
/**
* @package Grav\Common\Page
*
* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Page\Medium;
use Grav\Common\Data\Blueprint;
/**
* Class StaticImageMedium
* @package Grav\Common\Page\Medium
*/
class VectorImageMedium extends StaticImageMedium
{
/**
* Construct.
*
* @param array $items
* @param Blueprint|null $blueprint
*/
public function __construct($items = [], Blueprint $blueprint = null)
{
parent::__construct($items, $blueprint);
// If we already have the image size, we do not need to do anything else.
$width = $this->get('width');
$height = $this->get('height');
if ($width && $height) {
return;
}
// Make sure that getting image size is supported.
if ($this->mime !== 'image/svg+xml' || !\extension_loaded('simplexml')) {
return;
}
// Make sure that the image exists.
$path = $this->get('filepath');
if (!$path || !file_exists($path) || !filesize($path)) {
return;
}
$xml = simplexml_load_string(file_get_contents($path));
$attr = $xml ? $xml->attributes() : null;
if (!$attr instanceof \SimpleXMLElement) {
return;
}
// Get the size from svg image.
if ($attr->width > 0 && $attr->height > 0) {
$width = $attr->width;
$height = $attr->height;
} elseif ($attr->viewBox && \count($size = explode(' ', $attr->viewBox)) === 4) {
[,$width,$height,] = $size;
}
if ($width && $height) {
$this->def('width', (int)$width);
$this->def('height', (int)$height);
}
}
}