question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: image sizes

See original GitHub issue

Right now library doesn’t support custom sizing of images. But it would be a good thing to support it.

There is no standard about image sizes in markdown. But as markdown supports inline HTML, library might be parsing HTML arguments specified in <img> tag:

  • width=
  • height=
  • style="width: ; height: ;"

Another thing is what measure units to support. I suggest using:

  • % percent
  • px pixels (all other units pt, em defaults to pixels). And pixels should be treated as dp on Android

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
notiescommented, Jun 30, 2020

Hello @liweijian ,

there are multiple options to support images sizes now.

For example commonmark-java currently has an extension to specify width and height for an image - via ![alt](#){width=10 height=19} syntax. They had it implemented as a delimiter processor, but unfortunately these attributes are available for HTML rendering only. We could adopt similar solution.

Then, currently commonmark allows specifying title for an image with ![alt](# "title") syntax. So, for example ![IMAGE](quiver-image-url/CE441C33AC43C93AA252DD42A1E73DB9.jpg "=618x164") would be a relatively easy addition. Not sure if it is a good application for title, but still it is a possibility.

And finally, a custom inline processor could be implemented. It would require quite a few changes. You can inspect code in CloseBracketInlineProcessor class. I would not modify it directly as it would diverge Markwon and commonmark-java code bases, which is not a very welcome thing at this point. Anyway, if you feel like it, you can fork this class and adjust to your needs.

PS I should also mention that there is another way for specifying image size - HTML. markwon-html artifact supports width and height attributes from day 1

0reactions
notiescommented, Aug 2, 2020

Hello @ubuntudroid ,

I can confirm that this happens. Image loader would be asked to prepare image resource and after that ImageSizeResolver would do a final post processing. For example, when width=100% then it would scale the image (up or down depending on its original size). Another use-case is when image exceeds available width and will be scaled down to fit. A possible fix is to do resizing inside image loader itself (maybe the only one given the current state of things)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Change Your Featured Image Size in WordPress
A good starting point for your WordPress featured image size is 1200 x 628 pixels. These dimensions tend to work well across WordPress...
Read more >
Best WordPress Featured Image Size & Best Practices
While different themes have different featured image sizes, we recommend going with an image size of 1200 pixels by 628 pixels if you...
Read more >
How To Set The WordPress Featured Image Size - WPkind
Step 2 – Edit the WordPress featured image dimensions ; large, ; medium or ; thumbnail image sizes, you can change the corresponding...
Read more >
How To Change WordPress Featured Image Size in 2022?
The most recommended or ideal WordPress feature image size is 1200 by 628 pixels. This is one of the most common and widely...
Read more >
Change the Featured Image Size in WordPress
These properly named sizes are: Thumbnail (150px), Medium (300px), Medium Large (768px), and Large (1024px). Two more variants with 1536px and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found