Skip to content

Issue 391 Knowledge Images From Your Computer

Ed Mozley edited this page Nov 18, 2026 · 2 revisions

🖼️ #391 The Knowledge image dialog had no way to pick a picture from your computer

GitHub #391, reported by @acelr22 · Knowledge · fixed in 5.6.0 (#3000)

What you saw

Editing an article, the image button opened a dialog that only took a web address. There was no button to browse for a picture on your computer.

What was wrong

Nothing was broken: the dialog had simply never been given an upload handler. The article editor is TinyMCE, and its image dialog shows an Upload tab ("Drop an image here" / "Browse for an image") only when an images_upload_handler is configured. None was, so only the address field showed.

Pictures could already go into an article, by pasting or dragging them in: TinyMCE embeds those straight into the article's HTML as a data: image, and Knowledge stores the article as written. Most people would never have guessed that, though.

The fix

kbEmbedImage() in assets/js/knowledge.js is now the upload handler. TinyMCE sends pasted and dragged-in pictures through the same handler, so all three ways behave the same:

images_upload_handler: blobInfo => kbEmbedImage(blobInfo.blob()),
  • PNG, JPEG, GIF and WebP are accepted; anything else (SVG included) is refused with a message.
  • A large photo is scaled down to 1600px on its longest side before it is embedded, so an article doesn't carry megabytes of camera image. A PNG stays PNG (it may be transparent); a GIF is left untouched so an animation keeps moving.
  • Over 3 MB even after scaling, it is refused with a message.

Why embedded, and not stored as files? It is how pasted pictures already worked, so there is one behaviour, not two. Stored, permission-checked article images are what PR #378 brings for Knowledge migrations. They need an article that already exists, and this fix doesn't depend on them.

📁 Files

File Change
🟡 assets/js/knowledge.js images_upload_handler, kbEmbedImage()
⚪ knowledge/index.php Cache-buster
⚪ lang/*/knowledge.php Three messages, 9 languages
🟢 tests/knowledge-image-upload.php The real knowledge.js against pictures drawn on a canvas

How it was verified

Reproduced first in the real editor on a test install: the image dialog had no tabs, only the address field. After the fix it shows General and Upload, with Browse for an image.

tests/knowledge-image-upload.php: 6 passed. A 3200×2000 photo comes back 1600×1000; a large PNG stays PNG and is scaled; a small picture is unchanged; a GIF is untouched; plain text and an SVG are refused.

What this means for you

Update to 5.6.0, then in an article choose the image button, then Upload, then Browse for an image (or drop one onto it). Pasting and dragging work as before, now with large photos scaled down.

Related: Knowledge

FreeITSM

Getting Started

Modules

Multi-tenancy (planned)

Responses to feedback

Blue sky thinking

Bugs resolved

Pull requests

Links

Clone this wiki locally