【问题标题】:Change size of image in github flavored markdown without using HTML img tag?在不使用 HTML img 标签的情况下更改 github 风格的 markdown 中的图像大小?
【发布时间】:2020-11-04 10:17:03
【问题描述】:

我仅限于使用[]() 语法来渲染图像(而不是<img>)(此限制的原因是因为它目前被用作已知错误的解决方法)。

有没有办法使用 []() 约定(不使用<img>)来调整图像大小?

到目前为止,我已经尝试了一些没有奏效的方法。最值得注意的是:

在图片url末尾添加?s=200/&s=200参数(推荐here

到目前为止,我最好的解决方案是下载图像并调整其大小并重新上传。任何从 md 本身更改其大小或通过更改 url(例如通过参数等)的方式都会好得多

【问题讨论】:

  • 不,没有办法做到这一点。
  • 我对此有 99% 的把握,但我没有参考资料。我会把它作为评论留下,以防其他人可以提供更好的。

标签: github github-flavored-markdown


【解决方案1】:

图片的GFM (GitHub Flavored Markdown) 规范不包括任何尺寸属性。

意味着[]() 不会在其 HTML 生成的表单中包含任何 size 元素。

如果你 change the Markdown processor to Kramdown 获取 GitHub 页面,那么 this would work:

![test image size](/img/post-bg-2015.jpg){:class="img-responsive"}
![test image size](/img/post-bg-2015.jpg){:height="50%" width="50%"}
![test image size](/img/post-bg-2015.jpg){:height="700px" width="400px"}

使用 HTML 是可行的(前提是您使用图片的 https://raw.githubusercontent.com/,但在您的情况下这是不可能的。

<img src="https://your-image-url.type" width="100" height="100">

你可以试试,进行测试:

{:refdef: style="width: 10px; height: 10px"}
[![Octocat](https://github.githubassets.com/images/icons/emoji/octocat.png)](./somelink)
{: refdef}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-18
    • 2016-09-28
    • 2017-07-04
    • 2014-04-07
    • 2014-06-08
    • 2017-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多