user20185162
user20185162

Reputation: 1

Is there a way to resize the image height and width posted by django-CKeditor?

Edit: Noone is answering this problem it seems. I'm editing in the hopes for this to reach out to other peoples.

I'm using django 6.5.1 as of creating this project. I am unable to make the resize option remove. I want the upload image to get resized automatically in the html page as 100% width and height. My settings.py is:

CKEDITOR_CONFIGS = {
    'default': {
        'height': 90,
         'width': 700,
        # 'skin': 'moono',
        # # 'skin': 'office2013',
        # 'toolbar_Basic': [
        #     ['Source', '-', 'Bold', 'Italic']
        # ],
        'toolbar_Custom': [
            {'name': 'document', 'items': ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates']},
            {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
            {'name': 'editing', 'items': ['Find', 'Replace', '-', 'SelectAll']},
            {'name': 'forms',
             'items': ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
                       'HiddenField']},
            '/',
            {'name': 'basicstyles',
             'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
            {'name': 'paragraph',
             'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
                       'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl',
                       'Language']},
            {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
            {'name': 'insert',
             'items': ['Image', 'Youtube','Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe']},
            '/',
            {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
            {'name': 'colors', 'items': ['TextColor', 'BGColor']},
            {'name': 'tools', 'items': ['Maximize', 'ShowBlocks']},
            {'name': 'about', 'items': ['CodeSnippet']},
            {'name': 'about', 'items': ['About']},

        ],
        'toolbar': 'Custom',  # put selected toolbar config here
        'toolbarGroups': [{ 'name': 'document', 'groups': [ 'mode', 'document', 'doctools' ] }],
        'height': 400,
        'width': '100%',
        'filebrowserWindowHeight': 725,
        'filebrowserWindowWidth': 940,
        'toolbarCanCollapse': True,
        'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML',
        'tabSpaces': 4,
        'extraPlugins': ','.join([
            'uploadimage', # the upload image feature
            # your extra plugins here
            'div',
            'autolink',
            'autoembed',
            'embedsemantic',
            'autogrow',
            'devtools',
            'widget',
            'lineutils',
            'clipboard',
            'dialog',
            'dialogui',
            'elementspath',
            'codesnippet',
            
        ]),
    }
}

I have this script in post_form.html

<script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script>

Edit: the HTML code is:

{% extends "blog/base.html" %}
{% block content %}
    <article class="media content-section">
        <div class="media-body">
            <div class="article-metadata">
            <img class="rounded-circle article-img" src="{{ object.author.profile.image.url }}">
              <a class="mr-2" href="{% url 'user-posts' object.author.username %}">{{ object.author }}</a>
              <small class="text-muted">{{ object.date_posted|date:'F d, Y'}}</small>
              {% if object.author == user %}
            <div>
              <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{% url 'post-update' object.id %}">Update</a>
              <a class="btn btn-danger btn-sm mt-1 mb-1" href="{% url 'post-delete' object.id %}">Delete</a>
            </div>
          {% endif %}
            </p>

            <h2 class="article-title"> {{ object.title }} </h2>
            <img src="{{ post.image.url }}" class="rounded blog-pics-list" alt="post_img">
            <p class="article-content">{{ object.content | safe }}</p>
        </div>
    </article>
{% endblock content %}

What I want to do it to resize the image uploaded to CKEditor to

width: 100%;
height : 100%;

How can I achieve this?

Upvotes: 0

Views: 208

Answers (0)

Related Questions