Search code examples
htmlgithubimage-resizingorg-mode

Github org-mode html export image resizing


How to resize images in org-mode describes to resize images using #:ATTR_HTML. This has not worked for GitHub's org-mode export, though: adding

#:ATTR_HTML: :width 100px

works in emacs' export, but GitHub seems to omit it.

Is there any way to make GitHub resize an org-exported image?


Solution

  • As part of its rendering pipeline, after converting Org to HTML,

    The HTML is sanitized, aggressively removing things that could harm you and your kin—such as script tags, inline-styles, and class or id attributes.

    The sanitation rules used to be referenced here as well, but this reference was removed in October, 2018. As a result it is no longer clear which tags and attributes are permitted, but it is very likely that the generated width="100px" attribute is removed during this process.

    It is also possible that the Ruby library GitHub users to convert Org to HTML simply doesn't support ATTR_HTML.

    In either case, your best bet is probably to use a real 100px-wide version of that image.