Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/11.2' into 11.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	doc/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
  • Loading branch information
mattamon committed May 3, 2024
2 parents fa5c318 + 2a43640 commit ff116c6
Show file tree
Hide file tree
Showing 21 changed files with 316 additions and 44 deletions.
4 changes: 4 additions & 0 deletions bundles/ApplicationLoggerBundle/public/js/log/admin.js
Expand Up @@ -394,6 +394,10 @@ pimcore.bundle.applicationlogger.log.admin = Class.create({
this.store.load();
}
pimcore.layout.refresh();

this.panel.on("destroy", function () {
Ext.TaskManager.stop(this.autoRefreshTask);
}.bind(this));
}
return this.panel;
},
Expand Down
26 changes: 22 additions & 4 deletions bundles/CoreBundle/src/Command/ThumbnailsVideoCommand.php
Expand Up @@ -141,25 +141,43 @@ protected function waitTillFinished(int $videoId, string|Asset\Video\Thumbnail\C

// initial delay
$video = Asset\Video::getById($videoId);

if (!$video instanceof Asset\Video) {
$message = 'video ['.$videoId.'] could not be found. Skipping ...';
Logger::error($message);

return;
}

$thumb = $video->getThumbnail($thumbnail);
if ($thumb['status'] != 'finished') {
if ($thumb !== null && $thumb['status'] !== 'finished') {
sleep(20);
}

while (!$finished) {
\Pimcore::collectGarbage();

$video = Asset\Video::getById($videoId);

$thumb = $video->getThumbnail($thumbnail);
if ($thumb['status'] == 'finished') {

if ($thumb === null) {
$message = 'video ['.$videoId.'] with thumbnail ['.(is_string($thumbnail) ? $thumbnail : $thumbnail->getName()).'] is invalid. Skipping ...';
Logger::error($message);
$this->output->writeln($message);

break;
}

if ($thumb['status'] === 'finished') {
$finished = true;
Logger::debug('video [' . $video->getId() . '] FINISHED');
} elseif ($thumb['status'] == 'inprogress') {
} elseif ($thumb['status'] === 'inprogress') {
Logger::debug('video [' . $video->getId() . '] in progress ...');
sleep(5);
} else {
// error
Logger::debug('video [' . $video->getId() . "] has status: '" . $thumb['status'] . "' -> skipping");
Logger::debug('video [' . $video->getId() . "] has status: ['" . $thumb['status'] . "'] -> skipping ...");

break;
}
Expand Down
12 changes: 12 additions & 0 deletions bundles/CoreBundle/src/DependencyInjection/Configuration.php
Expand Up @@ -361,6 +361,18 @@ private function addAssetNode(ArrayNodeDefinition $rootNode): void
->arrayNode('assets')
->addDefaultsIfNotSet()
->children()
->arrayNode('thumbnails')
->addDefaultsIfNotSet()
->children()
->arrayNode('allowed_formats')
->defaultValue(['avif', 'eps', 'gif', 'jpeg', 'jpg', 'pjpeg', 'png', 'svg', 'tiff', 'webm', 'webp'])
->scalarPrototype()->end()
->end()
->floatNode('max_scaling_factor')
->defaultValue(5.0)
->end()
->end()
->end()
->arrayNode('frontend_prefixes')
->addDefaultsIfNotSet()
->children()
Expand Down
3 changes: 3 additions & 0 deletions bundles/GlossaryBundle/src/Tool/Processor.php
Expand Up @@ -192,6 +192,9 @@ private function prepareData(array $data): array
// fix htmlentities issues
$tmpData = [];
foreach ($data as $d) {
if (!($d['text'])) {
continue;
}
$text = htmlentities($d['text'], ENT_COMPAT, 'UTF-8');
if ($d['text'] !== $text) {
$td = $d;
Expand Down
Expand Up @@ -30,6 +30,7 @@
use Pimcore\Extension\Bundle\Exception\AdminClassicBundleNotFoundException;
use Pimcore\Model\Asset;
use Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\ClassDefinition\Data\Localizedfields;
use Pimcore\Model\Document;
use Pimcore\Model\Element;
use Pimcore\Model\Element\AdminStyle;
Expand Down Expand Up @@ -133,6 +134,7 @@ public function findAction(Request $request, EventDispatcherInterface $eventDisp
// filtering for objects
if (!empty($allParams['filter']) && !empty($allParams['class'])) {
$class = DataObject\ClassDefinition::getByName($allParams['class']);
$localizedFields = $class->getFieldDefinition('localizedfields');

// add Localized Fields filtering
$params = $this->decodeJson($allParams['filter']);
Expand All @@ -141,12 +143,12 @@ public function findAction(Request $request, EventDispatcherInterface $eventDisp

foreach ($params as $paramConditionObject) {
//this loop divides filter parameters to localized and unlocalized groups
$definitionExists = in_array($paramConditionObject['property'], DataObject\Service::getSystemFields())
|| $class->getFieldDefinition($paramConditionObject['property']);
if ($definitionExists) { //TODO: for sure, we can add additional condition like getLocalizedFieldDefinition()->getFieldDefiniton(...
if (in_array($paramConditionObject['property'], DataObject\Service::getSystemFields())) {
$unlocalizedFieldsFilters[] = $paramConditionObject;
} else {
} elseif ($localizedFields instanceof Localizedfields && $localizedFields->getFieldDefinition($paramConditionObject['property'])) {
$localizedFieldsFilters[] = $paramConditionObject;
} elseif ($class->getFieldDefinition($paramConditionObject['property'])) {
$unlocalizedFieldsFilters[] = $paramConditionObject;
}
}

Expand Down
14 changes: 12 additions & 2 deletions bundles/TinymceBundle/public/js/editor.js
Expand Up @@ -26,6 +26,8 @@ pimcore.bundle.tinymce.editor = Class.create({
if (e.detail.context === 'object') {
if (!isNaN(e.detail.config.maxCharacters) && e.detail.config.maxCharacters > 0) {
this.maxChars = e.detail.config.maxCharacters;
}else{
this.maxChars = -1;
}
}

Expand Down Expand Up @@ -83,6 +85,8 @@ pimcore.bundle.tinymce.editor = Class.create({
defaultConfig = pimcore[e.detail.context][subSpace].wysiwyg ? pimcore[e.detail.context][subSpace].wysiwyg.defaultEditorConfig : {};
}

const maxChars = this.maxChars;

tinymce.init(Object.assign({
selector: `#${this.textareaId}`,
height: 500,
Expand All @@ -96,12 +100,18 @@ pimcore.bundle.tinymce.editor = Class.create({
base_url: '/bundles/pimcoretinymce/build/tinymce',
suffix: '.min',
convert_urls: false,
convert_unsafe_embeds: true,
extended_valid_elements: 'a[class|name|href|target|title|pimcore_id|pimcore_type],img[class|style|longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align|pimcore_id|pimcore_type]',
init_instance_callback: function (editor) {
editor.on('input', function (eChange) {
tinymce.activeEditor.getBody().style.border = '';
tinymce.activeEditor.getElement().setAttribute('title', '');

const charCount = tinymce.activeEditor.plugins.wordcount.body.getCharacterCount();
if (this.maxChars !== -1 && charCount > this.maxChars) {
pimcore.helpers.showNotification(t('error'), t('char_count_limit_reached'), 'error');

if (maxChars !== -1 && charCount > maxChars) {
tinymce.activeEditor.getBody().style.border = '1px solid red';
tinymce.activeEditor.getElement().setAttribute('title', t('maximum_length_is') + ' ' + maxChars);
}
document.dispatchEvent(new CustomEvent(pimcore.events.changeWysiwyg, {
detail: {
Expand Down
2 changes: 1 addition & 1 deletion bundles/TinymceBundle/translations/admin.en.yaml
@@ -1,2 +1,2 @@
error: Error
char_count_limit_reached: The character limit has been reached!
maximum_length_is: The maximum length for this field is
1 change: 1 addition & 0 deletions doc/01_Getting_Started/README.md
Expand Up @@ -5,6 +5,7 @@ This section provides a quick getting started tutorial for Pimcore and covers th
1. Installation of Pimcore:
- via [Docker](../01_Getting_Started/00_Installation/00_Docker_Based_Installation.md)
- via [Webserver](../01_Getting_Started/00_Installation/01_Webserver_Installation.md)
- via [PaaS](https://pimcore.com/docs/platform/Paas/)
2. [Advanced Installation Topics](./02_Advanced_Installation_Topics/README.md):
- [Symfony Messenger and How to Handle Failed Jobs](./02_Advanced_Installation_Topics/01_Symfony_Messenger.md)
3. [Directory Structure of Pimcore](./03_Directory_Structure.md)
Expand Down
12 changes: 11 additions & 1 deletion doc/04_Assets/03_Working_with_Thumbnails/01_Image_Thumbnails.md
Expand Up @@ -9,7 +9,8 @@ which are not stored as an asset inside Pimcore.
> **IMPORTANT**
> Use Imagick PECL extension for best results, GDlib is just a fallback with limited functionality
> (only PNG, JPG, GIF) and less quality!
> Using ImageMagick Pimcore supports hundreds of formats including: AI, EPS, TIFF, PNG, JPG, GIF, PSD, ...
> Using ImageMagick Pimcore can support hundreds of formats including: AI, EPS, TIFF, PNG, JPG, GIF, PSD, etc.
> Not all formats are allowed out of the box. To extend the list [see](./README.md#allowed-formats).
To use the thumbnailing service of Pimcore, you have to create a transformation pipeline first. To do so, open
_Settings_ > _Thumbnails_ and click on _Add Thumbnail_ to create a new configuration.
Expand Down Expand Up @@ -329,6 +330,15 @@ This is a special functionality to allow embedding high resolution (ppi/dpi) ima
The following is only necessary in special use-cases like Web-to-Print, in typical web-based cases, Pimcore
automatically adds the `srcset` attribute to `<img>` and `<picture>` tags automatically, so no manual work is necessary.

The high resolution scaling factor is limited to `5.0` eg. `@5x`. Float values are supported.
If you need to scale an image more than that, you can use the `max_scaling_factor` option in the configuration.
```yaml
pimcore:
assets:
thumbnails:
max_scaling_factor: 6.0
```

### Use in the Thumbnail Configuration:

![High Resolution](../../img/thumbnail_high_resolution.png)
Expand Down
27 changes: 26 additions & 1 deletion doc/04_Assets/03_Working_with_Thumbnails/README.md
Expand Up @@ -4,7 +4,32 @@ Pimcore provides a sophisticated thumbnail processing engine for calculating thu
different output channels Pimcore can calculate and provide optimized images in terms of dimensions, file sizes, formats
and much more.

This functionality allows true single source publishing with Pimcore.
This functionality allows true single source publishing with Pimcore.

### Allowed formats
Pimcore allows the following formats for thumbnails out of the box:
`'avif', 'eps', 'gif', 'jpeg', 'jpg', 'pjpeg', 'png', 'svg', 'tiff', 'webm', 'webp'`.

If you want to use a different format, you can easily extend the list of supported formats.
Keep in mind that you must copy the whole list of formats and add your desired format to it.
```yaml
pimcore:
assets:
thumbnails:
allowed_formats:
- 'avif'
- 'eps'
- 'gif'
- 'jpeg'
- 'jpg'
- 'pjpeg'
- 'png'
- 'svg'
- 'tiff'
- 'webm'
- 'webp'
- 'pdf' # Add your desired format here
```

##### Thumbnails are available for following file types:
* [Image Thumbnails](./01_Image_Thumbnails.md)
Expand Down
30 changes: 30 additions & 0 deletions doc/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
Expand Up @@ -7,6 +7,36 @@
#### [Listing]
- The methods `setOrder()` and `setOrderKey()` throw an `InvalidArgumentException` if the parameters are invalid now.

## Pimcore 11.2.4
### Assets Thumbnails
- Thumbnail generation for Assets, Documents and Videos now only support the following formats out of the box: `'avif', 'eps', 'gif', 'jpeg', 'jpg', 'pjpeg', 'png', 'svg', 'tiff', 'webm', 'webp'`.
- You can extend this list by adding your formats on the bottom:
```yaml
pimcore:
assets:
thumbnails:
allowed_formats:
- 'avif'
- 'eps'
- 'gif'
- 'jpeg'
- 'jpg'
- 'pjpeg'
- 'png'
- 'svg'
- 'tiff'
- 'webm'
- 'webp'
- 'pdf' # Add your desired format here
```
- High resolution scaling factor for image thumbnails has now been limited to a maximum of `5.0`. If you need to scale an image more than that, you can use the `max_scaling_factor` option in the configuration.
```yaml
pimcore:
assets:
thumbnails:
max_scaling_factor: 6.0
```

## Pimcore 11.2.0
### Elements
#### [Documents]:
Expand Down
8 changes: 8 additions & 0 deletions models/Asset/Document/ImageThumbnail.php
Expand Up @@ -24,6 +24,7 @@
use Pimcore\Model;
use Pimcore\Model\Asset\Image;
use Pimcore\Model\Exception\NotFoundException;
use Pimcore\Model\Exception\ThumbnailFormatNotSupportedException;
use Pimcore\Tool\Storage;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\Lock\LockFactory;
Expand Down Expand Up @@ -70,8 +71,15 @@ public function getPath(array $args = []): string
return $path;
}

/**
* @throws ThumbnailFormatNotSupportedException
*/
public function generate(bool $deferredAllowed = true): void
{
if (!$this->checkAllowedFormats($this->config->getFormat())) {
throw new ThumbnailFormatNotSupportedException();
}

$deferred = $deferredAllowed && $this->deferred;
$generated = false;

Expand Down
13 changes: 13 additions & 0 deletions models/Asset/Image/Thumbnail.php
Expand Up @@ -24,6 +24,8 @@
use Pimcore\Model\Asset\Image\Thumbnail\Config;
use Pimcore\Model\Asset\Thumbnail\ImageThumbnailTrait;
use Pimcore\Model\Exception\NotFoundException;
use Pimcore\Model\Exception\ThumbnailFormatNotSupportedException;
use Pimcore\Model\Exception\ThumbnailMaxScalingFactorException;
use Pimcore\Tool;
use Symfony\Component\EventDispatcher\GenericEvent;

Expand Down Expand Up @@ -103,10 +105,21 @@ protected function useOriginalFile(string $filename): bool
}

/**
* @throws ThumbnailFormatNotSupportedException
* @throws ThumbnailMaxScalingFactorException
*
* @internal
*/
public function generate(bool $deferredAllowed = true): void
{
if (!$this->checkAllowedFormats($this->config->getFormat(), $this->asset)) {
throw new ThumbnailFormatNotSupportedException();
}

if (!$this->checkMaxScalingFactor($this->config->getHighResolution())) {
throw new ThumbnailMaxScalingFactorException();
}

$deferred = false;
$generated = false;

Expand Down
31 changes: 31 additions & 0 deletions models/Asset/Thumbnail/ImageThumbnailTrait.php
Expand Up @@ -16,6 +16,7 @@

namespace Pimcore\Model\Asset\Thumbnail;

use Pimcore\Config as PimcoreConfig;
use Pimcore\Helper\TemporaryFileHelperTrait;
use Pimcore\Model\Asset;
use Pimcore\Model\Asset\Image;
Expand Down Expand Up @@ -428,4 +429,34 @@ public function getAsFormat(string $format): static

return $thumb;
}

private function checkAllowedFormats(string $format, ?Asset $asset = null): bool
{
$format = strtolower($format);
if($asset) {
$original = pathinfo($asset->getRealFullPath(), PATHINFO_EXTENSION);
if ($format === $original || $format === 'source') {
return true;
}
}

$assetConfig = PimcoreConfig::getSystemConfiguration('assets');

return in_array(
$format,
$assetConfig['thumbnails']['allowed_formats'],
true
);
}

private function checkMaxScalingFactor(?float $scalingFactor = null): bool
{
if ($scalingFactor === null) {
return true;
}

$assetConfig = PimcoreConfig::getSystemConfiguration('assets');

return $scalingFactor <= $assetConfig['thumbnails']['max_scaling_factor'];
}
}

0 comments on commit ff116c6

Please sign in to comment.