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

No warning before referenced image is deleted (softref not working correctly?) #243

Closed biedert closed 1 year ago

biedert commented 1 year ago

Question Maybe I misunderstood the purpose of the RteImageSoftReferenceParser, but my expectation would be to get a warning when I try to delete an image which is referenced in a tt_content element with an image reference in the bodytext field. At least in my fresh installation of TYPO3 11.5 with rte_ckeditor_image installed, this is not the case. Am I missing something here?

Environment

Documentation Have you checked the readme/documentation?

Patta commented 1 year ago

I can confirm, that image reference is not working anymore. counter is 0. a warning log i written: Tue, 22 Aug 2023 14:20:12 +0200 [WARNING] request="0487ed6f1fbbe" component="TYPO3.CMS.Core.DataHandling.SoftReference.SoftReferenceParserFactory": No soft reference parser exists for the key "images". - {"parserKey":"images"}

magicsunday commented 1 year ago

I just tried this with version 11.0.13.

After adding an image in the RTE editor and saving it:

grafik grafik

A new entry should appear in the "sys_refindex" table. Filter the “softref_key” column for “rtehtmlarea_images” for instance.

grafik

When I try to delete the image via the backend, I get the following warning:

grafik

Gitsko commented 1 year ago

@biedert. @Patta can you please check if the problem still exists with the current version ? (v11.014)

sypets commented 1 year ago

After saving an element, the reference index should be updated automatically. You can check this by

  1. Looking in the file list - in the right column, the number of references is displayed und you can also click on it to get details

image

  1. (or) check table sys_refindex

I have noticed 2 problems so far with images inserted with rte_ckeditor_image and references:

  1. Saving the reference index did not always work. I think this should be fixed, not sure. (I am using a patched version, which works in TYPO3 v11). Ideally test with latest release!
  2. If you are using images in other RTE fields besides tt_content.bodytext: The softref parser'rtehtmlarea_images'must be added to the softref field in the TCA for all affected fields. (If the fields are enabling images to be inserted depends on your RTE configuration, so only necessary to do this where you need it). This is up to you to configure, it will not work out of the box! If you do not do this, the references will not be saved AFAIK.

e.g. Configuration/TCA/Overrides/tx_news_domain_model_news.php:

$softref = explode(',', $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['bodytext']['config']['softref'] ?? '');
    if (!in_array('rtehtmlarea_images', $softref, true)) {
        $softref[] = 'rtehtmlarea_images';
        $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['bodytext']['config']['softref'] = implode(',', $softref);
    }

You can also compare Configuration/TCA/Overrides/tt_content in rte_ckeditor_image.


If you have the possibility to debug, try setting a breakpoint in RteImageSoftReferenceParser::parse and findImageTags


Related issue: https://github.com/netresearch/t3x-rte_ckeditor_image/issues/45

Patta commented 1 year ago

@Gitsko this issue is solved for me, yes. update the softref tca as @sypets explained, also fixed this issue with third party extensions.