首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >微小MCE和Django

微小MCE和Django
EN

Stack Overflow用户
提问于 2020-10-19 08:57:11
回答 1查看 190关注 0票数 0

我想建立一个博客网站。我用的是微小的MCE和Django。我可以添加/上传照片到我的博客。但问题是,,通过微电脑上传的图像对手机屏幕这样的较小屏幕没有响应能力。文本响应良好,但图像却覆盖了。我查阅了一些微小的MCE文档,但没有找到答案。这是我的一组代码:

tinyinject.js:

(我对JS不太在行)

代码语言:javascript
复制
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js";
document.head.appendChild(script);
script.onload = function () {
    tinymce.init({
        selector: '#id_content',
        plugins: [
            'advlist autolink link image imagetools lists charmap print preview hr anchor pagebreak',
            'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
            'table emoticons template paste help'
        ],
        toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | ' +
            'bullist numlist outdent indent | link image | print preview media fullpage | ' +
            'forecolor backcolor emoticons | help | image',
        imagetools_toolbar: "rotateleft rotateright | flipv fliph | editimage imageoptions",
        image_title: true,
        automatic_upload: true,
        file_picker_types: 'image',
        file_picker_callback: function(cb, value, meta) {
            var input = document.createElement('input');
            input.setAttribute('type', 'file');
            input.setAttribute('accept', 'image/*');
            input.onchange = function() {
                var file = this.files[0];
                var reader = new FileReader();
                reader.onload = function() {
                    var id = 'blobid' + (new Date()).getTime();
                    var blobCache = tinymce.activeEditor.editorUpload.blobCache;
                    var base64 = reader.result.split(',')[1];
                    var blobInfo = blobCache.create(id, file, base64);
                    blobCache.add(blobInfo);
                    cb(blobInfo.blobUri(), {title: file.name});
                };
                reader.readAsDataURL(file);
            };
            input.click();
        },
        menu: {
            favs: { title: 'My Favorites', items: 'code visualaid | searchreplace | emoticons' }
        },
        menubar: 'favs file edit view insert format tools table help',
    });
}

需要帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-17 10:33:07

要获得响应图像,需要阻止TinyMCE向插入的图像添加像素宽度和高度。一种方法是使用image_dimensions: false。然后使用css来设置图像的宽度,一个常见的方法是使用img { width: 100%; max-width: 600px; },其中600px将是最大的图像宽度。下面是一个更复杂的TinyMCE演示如果你想深入研究图像造型

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64424133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档