Kunstmaan / KunstmaanBundlesCMS

An advanced yet user-friendly content management system, based on the full stack Symfony framework combined with a whole host of community bundles. It provides a full featured, multi-language CMS system with an innovative page and form assembling process, versioning, workflow, translation and media managers and much more.
https://kunstmaancms.be
MIT License
402 stars 186 forks source link

[MediaBundle] Bug: image chooser does not work anymore. #1367

Closed aistis- closed 7 years ago

aistis- commented 7 years ago

Hello, after an upgrade to I have noticed that image chooser on rich text editor does not work anymore.

When I select an image, a token is taken as a value instead of image URL. This is the cause https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/1225/files#diff-79fef42617236c3caeca65fbf0331b7cR212

screenshot

Same with link chooser:

screenshot

sandergo90 commented 7 years ago

Hi,

That is how it is supposed to work. If you read the changelog you will see that you need to pipe URL output in your twig to | replace_url. Then this token will be replaced by the URL.

aistis- commented 7 years ago

@sandergo90 thanks for the quick response. But this content is persisted to the database. So it in the end it is just:

<div class="message-or-whatever">{{ message.content|raw }}</div>

the field contains already formed HTML body. Where exactly do you suggest using replace_url? I believe /home/wut/Projects/crowdhouse/www/vendor/kunstmaan/bundles-cms/src/Kunstmaan/AdminBundle/Resources/ui/js/_url-chooser.js is taking data-path and pasting it directly to Rich editor :thinking:

sandergo90 commented 7 years ago

The twig should contain:

{{ message.content|replace_url|raw }}
aistis- commented 7 years ago

It works that way, but I found some other cases:

sandergo90 commented 7 years ago

Hi,

Yes that's correct. Every pagePart that contains URL tokens need to be passed to the replace_url function. You're first question is correct indeed. You can create an issue for this only.

Cheers

aistis- commented 7 years ago

I am thinking that rendering these kind of fields, it must be under one filter only like {{content|wysiwyg_field}} where under the hoot all required filters (raw and replace_url at the moment) would be attached. So when we had the third or forth filter necessary to correctly render the wysiwyg field, we would not need to change API in twig anymore.

Do you have any suggestions to workaround the this?

sandergo90 commented 7 years ago

Yeah that would be an excellent solution indeed.

I think we need to look into the ckeditor javascript. There maybe is a javascript function that we can change to replace the url. Don't know for the moment.

aistis- commented 7 years ago

Thanks for the answers, for a temporary workaround - I just added the filter to the twig for end users. Our admins somehow will have to live with this for a while :)

sandergo90 commented 7 years ago

Lol, indeed! We will fix it when we have the time ;)

mtnorthrop commented 7 years ago

I've run into this bug as well since upgrading to v4. Since clients are used to adding images directly into the rich text editor, it would be nice if this was still an option.

In other threads, I've read that Kunstmaan's position on this is that it's better to use page parts to add images instead of inserting them into the rich text editor, but in our case the RTE is being used in an admin list and I don't know of a way of using page parts inside of an admin list item (I think I'll open a new issue to ask whether there's a correct way of doing this.)

sandergo90 commented 7 years ago

Hi @mtnorthrop ,

Did you read the comments in this issue about adding the replace_url twig function ?

Sander

mtnorthrop commented 7 years ago

Hello @sandergo90 ,

Thanks for your reply; I did read about the replace_url twig function and it worked perfectly to get the images to display on the frontend, but the issue that I have is just with the images displaying in the rich text editor.

Since it looks like Kunstmaan is not interested in supporting this (and I understand and respect the reasoning behind this), I'm now looking for a way of using page parts in admin list items so that I can give users a way to mix rich text and images in admin list items without having to insert them through the rich text editor.

Devolicious commented 7 years ago

@mtnorthrop I Answered your question in https://github.com/Kunstmaan/KunstmaanBundlesCMS/issues/1431

Happy coding!

mtnorthrop commented 7 years ago

Thanks for the answer, I really appreciate it!