Mattermost, Inc.

How to define size of images

Sometimes images have a size that’s not suitable, like e.g. avatars when posting notifications from some tracking systems like through bots. I was wondering if there is a way to scale such images with either markdown or HTML and I tried these:

![avatar]( =50x50)
<img src="" width="50" height="50">

The first one just ignores the dimensions and the second one is printed as text and not interpreted as HTML. Am I doing something wrong or is this not supported by Mattermost? If the latter, any chance of getting support for this in the future?

Hi @jurgenhaas,

We don’t support that right now, but it’d be a great addition. It would just need some changes to our forked Markdown and then a small addition to the code that generates the HTML.

If you’re interested in working on that, feel free to submit a PR. If not, do you mind filing a feature request for this? That way, we can gather interest from the community and prioritize accordingly.

I’m happy to work on a PR. Any suggestion on how to setup a dev environment or even be able to test on my GitLab-integrated self-hosted live environment?

We’ve got instructions on how to set up a dev environment here on

And I was actually wrong in my previous post. You shouldn’t actually need to touch the markdown parser to do this. Markdown actually includes things after a space as part of the URL for some reason, so if you post

![avatar]( =50x50)

in a message, the image method in webapp/utils/markdown.jsx is called with the first argument as " =50x50" to generate the HTML. You can just change it to look for the size at the end of the href. If you added that and then some unit tests to the webapp/tests/ directory, that’d be amazing.

Managed to work on the PR on GitHub and I hope this is OK even though there is no Jira ticket available for this.

And let me quickly explain why I haven’t included a test: I wasn’t able to find a test for including images in the first place which would have been helpful to build on top of with various versions of image sizes. Hope this is OK too.

Thanks for the PR! It’s a bit busy around here with the holidays coming up, but hopefully we should get it reviewed before then.

Also with regards to adding tests, I’ve created a separate ticket to add those (which we could use since most of the text formatting doesn’t have automated tests). If you want to add some yourself, feel free to just add them to your PR or to let us know that you’re adding them separately.