how to scale image
My page contains a large image which stretch beyond the width of this component. I want the image to contain.
Use a custom renderer for the image type and specify a class name or inline styles:
function Image(props) {
return <img {...props} style={{maxWidth: '100%'}} />
}
<Markdown
source=""
renderers={{image: Image}}
/>
You'll have to figure out the right approach to styling it yourself, but this should give you all the flexibility you need.
Thanks for the custom renderer code. Are there any plans to support scaling like mentioned at https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#images? I may have some time in the future to draft a PR.
renderers is remove in latest version
@dellwatson I think now you can use components instead of renderers to achieve a similar result as below.
<ReactMarkdown children={source}
components={{img:({node,...props})=><img style={{maxWidth:'100%'}}{...props}/>}}
/>
@dellwatson It works.
@RukshanJS Any chance you could provide ts example how to use that img:XX value but from different file? I'm struggling to provide correct arguments to standalone component :/