CKEditor: Extra image options when inserting MediaItem from MediaLibrary in editor #3339
Replies: 25 comments
-
I'm not sure I agree with the distorted images comment. If in css you define only the width or the height (not both) you won't get any distortion or I'm I wrong? |
Beta Was this translation helpful? Give feedback.
-
It is true that this will work with only height or width. Downside of only using the css-classes is also that you re limited to the classes you have made with width and height. End-user is not free to deterime his own dimensions. |
Beta Was this translation helpful? Give feedback.
-
@bramds and in that case aren't we allowing the user to break the design in case he uploads an image that is too big, too small, too wide or too high? |
Beta Was this translation helpful? Give feedback.
-
@ohvitorino maybe, but it gives more flexibility to create matching lay-outs too. With a bit of guidance you could make your end-users aware of how to use it? However I do think we agree, there needs to be some way to controle the dimensions of the image. |
Beta Was this translation helpful? Give feedback.
-
@bramds maybe only allow the width to be set and keep the height on auto? |
Beta Was this translation helpful? Give feedback.
-
you can do the cropping in the media library |
Beta Was this translation helpful? Give feedback.
-
How it now works
How it should work in the future
Conclusion |
Beta Was this translation helpful? Give feedback.
-
I disagree @jeroendesloovere since that would require the dev to add every possible filter that the customer want, not scalable enough |
Beta Was this translation helpful? Give feedback.
-
imagine has dynamic size filters, for example I'll try and see if I can get CKEditor to make this renderable |
Beta Was this translation helpful? Give feedback.
-
Like @StijnVrolijk says, if we program a variable that behaves like [MediaLibraryItem:10:500x100], the |
Beta Was this translation helpful? Give feedback.
-
@jeroendesloovere I tested that. Problem with that is everything in CKEditor gets parsed as a HTML file. If you put If you somehow resize the image on the fly the URL you receive is a cached URL so if that expires you're out of luck again. I've discussed some possible solutions with @carakas and @ohvitorino but we've come up empty. Some possible solutions were:
|
Beta Was this translation helpful? Give feedback.
-
Just to keep this updated: couldnt we just implement the css class + height and width? At the end it is the end-user who might need it, an extra feature is always good to have and with some plain css we can prevent it from breaking the layout... |
Beta Was this translation helpful? Give feedback.
-
Well, it's not always a case that an extra feature is a good thing 🙂 But in this case it seems to me that maybe the user should have the possibility to control the image's size when inserting it the editor, either by using css or the dimensions. I'll make a PR when I have the time, and then we'll see if it gets merged. |
Beta Was this translation helpful? Give feedback.
-
@StijnVrolijk, you mention In the database (using backend) this can be: Not? |
Beta Was this translation helpful? Give feedback.
-
@jeroendesloovere unfortunately not, parsing text in your template is apparently the last step in the twig process. So unless you specifically put Try the following:
It won't work |
Beta Was this translation helpful? Give feedback.
-
Maybe, we could do something like this: MediaItems.html.twig {% for mediaItem in mediaItems %}
{% set processedImages = processedImages|merge(
{
mediaItem.uniqueId: asset(mediaItem.image)|imagine_filter(mediaItem.filter, { thumbnail: { size: [mediaItem.width, mediaItem.height] }})
}
) %}
{% endfor %} myTemplate.html.twig {% set myText = "This is my text, this is an image: [MediaItemWithUniqueId]" %}
{% for image in myTemplateImages %}
{{ myText|replace('someRegexToCaptureTheMediaItemString', attribute(_context, 'processedImages[' ~ theUniqueIdSomehow ~ ']') }}
{% endfor %}
{{ myText|raw }} Something like that, it's purely theoretical and still has some things I'm not sure how to do... It's just a thought, maybe it can work |
Beta Was this translation helpful? Give feedback.
-
What about the other way around
Then the PHP method can fetch [MediaItem:< ID >:<width/height>] structure and output anything we like in a HTML format => We just need HTML that works. Which means that we don't need to convert to {{ asset(...)|imagine_... }} |
Beta Was this translation helpful? Give feedback.
-
In the future we could also introduce other shortcuts like f.e.: [Page:10:'url'].
|
Beta Was this translation helpful? Give feedback.
-
I'm sure this will work, since the "Media widgets" work the same way.
|
Beta Was this translation helpful? Give feedback.
-
How are you going to generate the custom sized image? |
Beta Was this translation helpful? Give feedback.
-
https://github.com/liip/LiipImagineBundle#runtime-options Using PHP <?php
$runtimeConfig = array(
"thumbnail" => array(
"size" => array(50, 50)
)
);
?>
<img src="<?php $this['imagine']->filter('/relative/path/to/image.jpg', 'my_thumb', $runtimeConfig) ?>" /> |
Beta Was this translation helpful? Give feedback.
-
@StijnVrolijk, ok, problem solved?! |
Beta Was this translation helpful? Give feedback.
-
hm, perhaps. could you try to implement it? |
Beta Was this translation helpful? Give feedback.
-
@StijnVrolijk We first need to find a solution in the backend for: "How are we going to show an image for [MediaItem:1]"? Any suggestions? ================ |
Beta Was this translation helpful? Give feedback.
-
Type
Problem description
Since we have dropped ckfinder, we now include images in the editor through the media libray. Now we can set the path and the alt text of the image. In some cases it could be usefull that you re able to also set:
This way we can control the image more in the frontend. ( setting width and height with the css class alone wouldnt work, because the dimension would be hardcoded in css and may distort some images )
Beta Was this translation helpful? Give feedback.
All reactions