Django - CKeditor dynamic image size based on client device

524 Views Asked by At

I'm trying to develop a blog style website and I use Django as web framework, CKeditor as wygiwys and Filer for file management (linked with CKeditor with django-ckeditor-filebrowser-filer).
It's all working, but the problem is that I can't control the image size for the images used inside the posts, I'd like to serve them based on user's device (smaller on mobile, larger on desktop, etc..).
I have no idea how to do that, any ideas? thanks

EDIT:
An idea would be: the CKeditor makes the html block and then send it to the client with the filer image src (like 'media/uploads/46813413/12'), then again from the server intercept the request to the filer media and send a resized image based on the the device that made the request. But is it possible to manage the filer requests?

1

There are 1 best solutions below

0
Gokul nath On

This can be configured in the settings.py file. Specify the width & height as 100% like below,

CKEDITOR_CONFIGS = {
    'default': {
        'height': '100%',
        'width': '100%',
    },
}

If you want to more or less height, you can use like 'height': '200'.

You can do much more configuration with ckeditor, refer to official documentation