Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide documentation for cropping #371

Closed
georgringer opened this issue Jul 7, 2017 · 9 comments
Closed

Provide documentation for cropping #371

georgringer opened this issue Jul 7, 2017 · 9 comments
Assignees

Comments

@georgringer
Copy link
Owner

Add some documentation how to add cropping information to field fal_media

@wojtablo
Copy link

wojtablo commented Jul 7, 2017

Ideally if "how to" guidelines would relate to official feature: #75880 release notes. Explain how to add multiple cropping variants for fal_media, eg. variant for media and desktop.

@Kleisli
Copy link

Kleisli commented Oct 4, 2017

Hi @georgringer
Can you give a little hint how to achieve this in a clean way?
I managed it, by hacking the code below into the tx_news_domain_model_news-TCA file in ['fal_media']['config'], but I am unable to do it in a TCA/Overrides-File in my own extension.. :-(

'overrideChildTca' => [
    'columns' => [
        'crop' => [
            'config' => [
                'cropVariants' => [
                    'mobile' => [
                        'title' => 'Mobile',
                        'allowedAspectRatios' => [
                            '4:3' => [
                                'title' => '4 zu 3',
                                'value' => 4 / 3
                            ],
                            'NaN' => [
                                'title' => 'FREI',
                                'value' => 0.0
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
],

Vielen Dank und liebe Grüsse
Till

@Kleisli
Copy link

Kleisli commented Oct 4, 2017

Nevermind, sometimes asking helps to find the solution yourself. :)

Here is a working (TYPO3 8.7 / news 6.0) snippet to have special cropping settings just for the news items, just create a file your_extension/Configuration/TCA/Overrides/tx_news_domain_model_news.php with

<?php
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['fal_media']['config']['overrideChildTca']['columns']['crop'] = [
	'config' => [
		'cropVariants' => [
			'mobile' => [
				'title' => 'Mobile',
				'allowedAspectRatios' => [
					'4:3' => [
						'title' => '4 zu 3',
						'value' => 4 / 3
					],
					'NaN' => [
						'title' => 'FREI',
						'value' => 0.0
					],
				],
			],
		],
	],
];

and to use a specific cropVariant in your template add cropVariant="mobile" to the f:image-viewhelper.

@rowild
Copy link
Contributor

rowild commented Jan 16, 2018

@Kleisli Thanks, Till! For completeness, a fluid template example would be great, too.

@georgringer georgringer added this to the 7.0.0 milestone Mar 26, 2018
@josefglatz josefglatz self-assigned this Mar 30, 2018
@josefglatz
Copy link
Contributor

josefglatz commented Mar 30, 2018

I will take over this task

As this is "just" an TYPO3 extension I would say it's not really the optimal place to add technical infos on how you can configure cropVariants in the TCA.

But to get an compact overview for EXT:news I would suggest following HowTos/Examples:

  • Howto set default cropVariants for tx_news_domain_model_news.columns.column
  • Howto overwrite cropVariants for tx_news_domain_model_news.columns.column for a specific tx_news_domain_model_news.type

Each of the above mentioned points with:

  • TCA configuration example
  • Fluid example

Does it suit almost everybody needs? Did I forgot something? (CC @georgringer @rowild )

@georgringer georgringer removed the t3dd label Apr 3, 2018
@georgringer georgringer modified the milestones: 7.0.0, 7.1 Apr 17, 2018
@georgringer
Copy link
Owner Author

@josefglatz are you still interested in doing it?

@georgringer georgringer removed this from the 7.1 milestone Apr 9, 2019
@medarob
Copy link
Contributor

medarob commented Jul 10, 2019

@josefglatz @georgringer I just want to add some cropVariants to news images and I discovered this issue. Is a more detailed documentation about this topic still work in progress (I saw that the last entry is amlost 1 year old)? If not I will try it on my own and could share my findings.

@peterkraume
Copy link
Sponsor Contributor

I just tried to add an additional crop variant for images in the list view.

When using the above mentioned code snippet, the default cropVariants always vanished. So I ended up copying the default cropVariants from the TYPO3 core (typo3/sysext/backend/Classes/Form/Element/ImageManipulationElement.php) and then adding my stuff afterwards:

$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['fal_media']['config']['overrideChildTca']['columns']['crop'] = [
    'config' => [
        'cropVariants' => [
            'default' => [
                'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.crop_variant.default',
                'allowedAspectRatios' => [
                    '16:9' => [
                        'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.16_9',
                        'value' => 16 / 9
                    ],
                    '3:2' => [
                        'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.3_2',
                        'value' => 3 / 2
                    ],
                    '4:3' => [
                        'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.4_3',
                        'value' => 4 / 3
                    ],
                    '1:1' => [
                        'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.1_1',
                        'value' => 1.0
                    ],
                    'NaN' => [
                        'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.free',
                        'value' => 0.0
                    ],
                ],
                'selectedRatio' => 'NaN',
                'cropArea' => [
                    'x' => 0.0,
                    'y' => 0.0,
                    'width' => 1.0,
                    'height' => 1.0,
                ],
            ],
            'newslistview' => [
                'title' => 'LLL:EXT:my_theme_ext/Resources/Private/Language/Tca.xlf:cropvariant.newslistview.title',
                'allowedAspectRatios' => [
                    '4:3' => [
                        'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.4_3',
                        'value' => 4 / 3
                    ],
                ],
            ],
        ],
    ],
];

Is this the way to go or is there a better solution?

By the way @josefglatz, I'd also appreciate a documentation of the cropVariants feature.

@georgringer
Copy link
Owner Author

I would go with extensions like melon_images, won't provide a documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants