使用 Timthumb 从 CKEditor 调整图像大小

发布于 2024-08-23 07:58:08 字数 483 浏览 1 评论 0原文

我正在使用 CKEditor 在我的网站中进行基本文本和图像输入。我注意到,当您添加图像时,它为图像生成 HTML 的方法非常零散。 (有时它可能使用高度和宽度标签,有时它可能使用 CSS)。

我使用 Timthumb 在许多其他网站上动态调整图像大小,发现它非常有用。我在 .htaccess 文件中使用 mod_rewrite 规则,以允许我创建类似 http://localhost/images 的域/800x600/image.jpg 并实现调整大小。

我想以某种方式将其合并到 CKEditor 中。我无法通过查看文档找到如何执行此操作,因此我尝试使用 Regex 对 CKEditor 生成的数据进行后处理,但是正如前面提到的,CKEditor 似乎过于零散,无法使其始终正常工作。

以前还有其他人这样做过吗?你是如何实现的?

I am using CKEditor to do basic text and image input into my website. I have noticed that it is quite sporadic in it's method of generating HTML for images when you add them. (Sometimes it might use height and width tags, other times it might use CSS).

I use Timthumb for on the fly image resizing on a number of other websites and find it very useful. I use a mod_rewrite rule in my .htaccess file to allow me to create domains like http://localhost/images/800x600/image.jpg and achieve resizing.

I would like to somehow incorporate this into CKEditor. I cannot find how to do this looking through the documentation so I have tried post-processing the data produced by CKEditor using Regex, however as mentioned before CKEditor seems to be too sporadic to be able to get this to work all the time.

Anyone else done this before? How did you achieve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

这个俗人 2024-08-30 07:58:08

我已经在 Grails 中做到了这一点。由于随意使用html属性和css,这是相当痛苦的。我最终使用了 html 解析器,迭代图像(dom 节点)并调整已调整大小的图像的大小。之后,必须更新 html 属性和/或 css 样式。花了相当长的时间才把它弄好,因为有很多事情可能会出错。

I've done this in Grails. It's quite painful because of the random usage of html attributes and css. I ended up using an html parser, iterating over the images (dom nodes) and resizing those who has been resized. After that the html attributes and/or css styles has to be updated. It took quite some time to get it right as there are so many things that can go wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文