Sometimes images have a size that’s not suitable, like e.g. avatars when posting notifications from some tracking systems like github.com through bots. I was wondering if there is a way to scale such images with either markdown or HTML and I tried these:
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?
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?
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
in a message, the image method in webapp/utils/markdown.jsx is called with the first argument as "https://example.com/avatar/user.png =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.
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.
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.