Skip to content

Commit

Permalink
Merge pull request #1 from visol/task/typo3-10lts
Browse files Browse the repository at this point in the history
Task/typo3 10lts
  • Loading branch information
lorenzulrich authored Apr 6, 2021
2 parents 9a141b9 + 78404b8 commit fbc0e53
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 2,207 deletions.
511 changes: 0 additions & 511 deletions Classes/DataProcessing/GalleryProcessor.php

This file was deleted.

5 changes: 3 additions & 2 deletions Classes/DataProcessing/ResponsiveGalleryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
namespace Visol\Viresponsiveimages\DataProcessing;

use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException;
use TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor;

/**
* passing imageorient to fluid where a custom viewhelper handles the output of sourcesets
* based on several settings and can be used for f.i. the CType "textmedia"
* Passing imageorient to fluid where a custom Viewhelper handles the output of source sets
* based on several settings and can be used for e.g. the CType "textmedia"
*/
class ResponsiveGalleryProcessor extends GalleryProcessor
{
Expand Down
14 changes: 7 additions & 7 deletions Classes/Service/SrcSetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Resource\AbstractFile;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Extbase\Service\ImageService;

/**
* Render the srcset attribute with responsive images. Accepts mostly the same parameters as the uri.image ViewHelper of the Neos.Media package:
* asset, maximumWidth, maximumHeight, allowCropping, ratio.
*
*/
class SrcSetService
{

/**
* @var \TYPO3\CMS\Extbase\Service\ImageService
* @var ImageService
*/
protected $imageService;

/**
* @param \TYPO3\CMS\Extbase\Service\ImageService $imageService
* @param ImageService $imageService
*/
public function injectImageService(\TYPO3\CMS\Extbase\Service\ImageService $imageService)
public function injectImageService(ImageService $imageService)
{
$this->imageService = $imageService;
}
Expand All @@ -43,10 +43,10 @@ public function injectImageService(\TYPO3\CMS\Extbase\Service\ImageService $imag
* @param float $ratio
* @param int $maximumWidth
* @param int $maximumHeight
* @param boolean $allowCropping
* @param int $quality
* @param string $crop
* @param string $cropVariant
* @param array $sizes
* @param RequestInterface $request
* @param boolean $absolute
* @return string
* @throws \Exception
*/
Expand Down
14 changes: 7 additions & 7 deletions Classes/ViewHelpers/ResponsiveImageViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper;
use Visol\Viresponsiveimages\Service\SrcSetService;

/**
* Resizes a given image (if required) and renders the respective img tag
Expand Down Expand Up @@ -62,29 +63,28 @@
* Could not get image resource for "NonExistingImage.png".
* </output>
*/
class ResponsiveImageViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper
class ResponsiveImageViewHelper extends ImageViewHelper
{

/**
* allow multidigit ratio values like 1024:768 or 4:3
*/
const RATIO_PATTERN = '/(\d+):(\d+)/';


/**
* @var string
*/
protected $tagName = 'img';

/**
* @var \Visol\Viresponsiveimages\Service\SrcSetService
* @var SrcSetService
*/
protected $srcSetService;

/**
* @param \Visol\Viresponsiveimages\Service\SrcSetService $srcSetService
* @param SrcSetService $srcSetService
*/
public function injectSrcSetService(\Visol\Viresponsiveimages\Service\SrcSetService $srcSetService)
public function injectSrcSetService(SrcSetService $srcSetService)
{
$this->srcSetService = $srcSetService;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ public function render()
}
$sizes = GeneralUtility::intExplode(',', $sizesCsv, true);

$srcSetString = $this->srcSetService->getSrcSetAttribute($image, $ratio, $maximumWidth, $maximumHeight, $crop, $cropVariant, $sizes, null);
$srcSetString = $this->srcSetService->getSrcSetAttribute($image, $ratio, $maximumWidth, $maximumHeight, $crop, $cropVariant, $sizes);
$classNames = ['lazyload'];
if (isset($this->arguments['class'])) {
$classNames[] = $this->arguments['class'];
Expand Down
8 changes: 5 additions & 3 deletions Classes/ViewHelpers/SrcSetViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;

/**
* Resizes a given image (if required) and renders the respective img tag
Expand Down Expand Up @@ -61,7 +63,7 @@
* Could not get image resource for "NonExistingImage.png".
* </output>
*/
class SrcSetViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
class SrcSetViewHelper extends AbstractViewHelper
{

const RATIO_PATTERN = '/(\d):(\d)/';
Expand Down Expand Up @@ -122,7 +124,7 @@ public function initializeArguments()
*
* @see https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Image/
*
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
* @throws Exception
* @return string Rendered tag
*/
public function render()
Expand Down Expand Up @@ -156,7 +158,7 @@ public function render()
}
$sizes = GeneralUtility::intExplode(',', $sizesCsv, true);

$srcSetString = $this->srcSetService->getSrcSetAttribute($image, $ratio, $maximumWidth, $maximumHeight, $crop, $cropVariant, $sizes, null);
$srcSetString = $this->srcSetService->getSrcSetAttribute($image, $ratio, $maximumWidth, $maximumHeight, $crop, $cropVariant, $sizes);
} catch (ResourceDoesNotExistException $e) {
// thrown if file does not exist
} catch (\UnexpectedValueException $e) {
Expand Down
14 changes: 14 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

Visol\Viresponsiveimages\:
resource: '../Classes/*'

Visol\Viresponsiveimages\Service\SrcSetService:
public: true

Visol\Viresponsiveimages\DataProcessing\ResponsiveGalleryProcessor:
public: true
60 changes: 0 additions & 60 deletions Configuration/Styling/setup.typoscript

This file was deleted.

4 changes: 2 additions & 2 deletions Configuration/TSconfig/Page/All.typoscript
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# PageTS for viresponsiveimages
#
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:viresponsiveimages/Configuration/TSconfig/Page/TCEFORM.typoscript">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:viresponsiveimages/Configuration/TSconfig/Page/TCEMAIN.typoscript">
@import 'EXT:viresponsiveimages/Configuration/TSconfig/Page/TCEFORM.typoscript'
@import 'EXT:viresponsiveimages/Configuration/TSconfig/Page/TCEMAIN.typoscript'
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ page.includeJSFooterlibs {
lazysizes9core = EXT:viresponsiveimages/Resources/Private/Javascripts/lazysizes/lazysizes.min.js
}

<INCLUDE_TYPOSCRIPT: source="FILE:EXT:viresponsiveimages/Configuration/Styling/setup.typoscript">

<INCLUDE_TYPOSCRIPT: source="FILE:EXT:viresponsiveimages/Resources/Private/TypoScript/ContentElement/Image.typoscript">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:viresponsiveimages/Resources/Private/TypoScript/ContentElement/Textpic.typoscript">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:viresponsiveimages/Resources/Private/TypoScript/ContentElement/Textmedia.typoscript">

@import 'EXT:viresponsiveimages/Configuration/TypoScript/ContentElement/Image.typoscript'
@import 'EXT:viresponsiveimages/Configuration/TypoScript/ContentElement/Textpic.typoscript'
@import 'EXT:viresponsiveimages/Configuration/TypoScript/ContentElement/Textmedia.typoscript'
Loading

0 comments on commit fbc0e53

Please sign in to comment.