netresearch / t3x-rte_ckeditor_image

Image support in CKEditor for the TYPO3 ecosystem
GNU Affero General Public License v3.0
56 stars 65 forks source link

Settings maxWidth/maxHeight not working for magic images, page TS Config is missing #131

Closed kanow closed 9 months ago

kanow commented 3 years ago

Hi, I had the problem with the maxWidht/maxHeight settings they not working. maxWidth is always 300 after saving the data. I tried solutions from older issues here. But they don't helps me to fix it.

I did some debugging and find out that the page ts config is missing for that RTE.default.buttons…

If I use those settings

RTE.default.buttons.image.options.magic {
    maxWidth = 1125  
    maxHeight = 900  
}

in page properties in backend they are not in the $tsConfig variable in Classes/Database/RteImagesDbHook.php transform_db() method, Line: 111

If I add the configuration to my page ts file which will be included in my project, then the configuration is in that variable $tsConfig and maxWidth/Height settings will be respected after saving the data and also in frontend.

I think there is something wrong with that parser stuff

// Parse the PageTS into an array, also applying conditions
            $parser = GeneralUtility::makeInstance(
                PageTsConfigParser::class,
                GeneralUtility::makeInstance(TypoScriptParser::class),
                GeneralUtility::makeInstance(CacheManager::class)->getCache('hash')
            );
            $matcher = GeneralUtility::makeInstance(ConditionMatcher::class, null, $pageId, $rootLine);
            $tsConfig = $parser->parse($tsConfigString, $matcher);

The value of $pageId was also wrong. That was not the page in backend where I save the data.

I use TYPO3 10.4.14 and rte_ckeditor_image 10.1.0

merzilla commented 2 years ago

Hi, I have a similar issue that the wrong TSconfig gets loaded. As far as I found out is that $pageId = GeneralUtility::makeInstance(BackendConfigurationManager::class)->getDefaultBackendStoragePid(); in the DB hook gets the value for the template of the very first rootpage in the pagetree. So let's say I have 4 domains in the system, the root pages are e.g. uids 10, 20, 30, 40. Then if I debug the $tsconfig in RTE when I save of page 40, it shows me the settings of page 10.

Maybe it is a bug of the BackendConfigurationManager that does not detect the correct rootline / root page?

Edit: Even if I log into the backend with the domain of page 40, it detects uid 10 to be the root page when I save RTE data.

stoppeye commented 2 years ago

The problem is indeed with BackendConfigurationManager, which returns total crap. See https://forge.typo3.org/issues/93251

According to my testing, it is primarily the query in method getCurrentPageIdFromCurrentSiteRoot() that returns faulty results.

I tried to come up with a more reliable solution myself, but can understand now, why this issue was labeled "help wanted"...

Considering that the hook transform_db() is marked deprecated as of V11, it's probably not worth fixing it anyway. Since the API docs recommend using page TSconfig, it might be worth looking into that.

Gitsko commented 10 months ago

Hi @kanow,

sorry for the late response, I think in the latest version there should be no more problems with the max height or width. See also in https://github.com/netresearch/t3x-rte_ckeditor_image/issues/246. I hope this can help.

Can you please confirm that it works or is there still a problem?

kanow commented 9 months ago

Sorry, for the moment I don't know in which project I had used this extension :grin: It's a little bit to late to test this. But if you say it's fixed, then it's ok I think. Let's close the issue. Thx.