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

Image conversion inside custom column of pages table #222

Closed bigahuna closed 1 year ago

bigahuna commented 1 year ago

Question

Hi all,

We use the extension in a couple of projects and it's working fine. But during an update of a project from TYPO3 v10 to v11 we found an issue that I was not able to resolve.

We have a custom column inside the pages table.

In myext:ext_tables.sql is this code:

CREATE TABLE pages (
  custom_col text,
);

and in myext:Configuration/TCA/Overrides/pages.php we have

<?php 
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', array(
    'custom_col' => [
        'label' => 'Custom Col',
        'config' => [
        'type' => 'text',
        'enableRichtext' => true
        ]
    ]
));

In the TYPO3 backend everything works as expected. We can insert images inside the RTE in the text for 'custom_col'.

But in the frontend the resulting image is rendered like this:

<img 
    alt="lorem ipsum" 
    data-htmlarea-file-table="sys_file" 
    data-htmlarea-file-uid="174" 
    width="1000"
    height="516"    
    src="typo3/image/process?token=532d92f52f4025536d789b046bce06189b2e2924&id=3419" 
    style="" 
    title="" />

For "normal" page-content the images are translated to the correct fileadmin paths (i.e. src="/fileadmin/processed/0/e/csm_blabla_114ca5279c.jpg" ), but not for the column inside the pages table.

We stumbled upon this problem because we deleted the fileadmin/_processed folder during the update. Images inserted in RTE for tt_content where recreated, but images inside columns of the pages table where not. They ended up with links like this one typo3/image/process?token=xyz

So my question is, if there is a way to make the rte_ckeditor_image extension work for a columns inside the pages table or if it is only working for columns inside tt_content or for content inside mask tables?

Environment

Documentation Have you checked the readme/documentation?

magicsunday commented 1 year ago

Hi, could you please try the latest version from the master-branch? There was a bug fixed yesterday (https://github.com/netresearch/t3x-rte_ckeditor_image/commit/1ceccac5458112b3c37268a70b4a60ee7f457dc7) which may solve your problem too.

bigahuna commented 1 year ago

Hi,

Thanks for the reply. I tried the latest version and it is an improvement.

Now the created link is correct (/fileadmin/processed/6/4/csm_blabla_97ebd6d0e8.jpg) and the rendered image tag looks like this

<img 
    alt="" 
    data-alt-override="true" 
    data-htmlarea-file-table="sys_file" 
    data-htmlarea-file-uid="120" 
    data-title-override="true" 
    height="516" 
    src="/fileadmin/_processed_/6/4/csm_blabla_97ebd6d0e8.jpg" 
    style="" 
    title="" 
    width="1000"/>

Now if I delete the files inside /fileadmin/_processed with the install tool, the created image path stays the same but the image is not recreated inside _processed.

So trying to load /fileadmin/processed/6/4/csm_blabla_97ebd6d0e8.jpg fails with a 404 error.

Right now the install tool module that deletes temporary files inside the _processed folder results in hundreds of not working images all over the site.

A temporary solution is to open the related RTE field in the backend and save it again. Now the image inside fileadmin/_processed is recreated and everything works. But this is not something one would like to do for hundreds or thousands of contentpages.

So instead of creating the images inside fileadmin/_processed only after saving the backend element, there should be a check on each request if this temporary image exists. If not, create it. Or maybe an console command that checks all images and recreates them if they do not exist.

If I can be of any help during development, I will be glad to do so. I just need a little help where to look and start because I'm not familiar with this extension.

Regards Mike

bigahuna commented 1 year ago

Hi all,

I found the solution. Sorry for this task that - now that I know the solution - maybe looks a litte bit stupid.

Just use the following code on custom fields inside fluid templates and all works as expected

<f:format.html parseFuncTSPath="lib.parseFunc">{v:page.info(field:'custom_col')}</f:format.html>

Using parseFuncTSPath="lib.parseFunc" was my missing code...

Thanks again for the fast answers!

Regards Mike