Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown image size is incorrect #8

Closed
ssmlee04 opened this issue Oct 10, 2016 · 14 comments
Closed

Markdown image size is incorrect #8

ssmlee04 opened this issue Oct 10, 2016 · 14 comments

Comments

@ssmlee04
Copy link

ssmlee04 commented Oct 10, 2016

When I was trying to display this image

The screen seems to display only the center of the image for some reason

Is there something that I did wrong?

@CharlesMangwa
Copy link
Owner

Hi! Can you show me your code plz? I have an idea about what could be the problem.

@ssmlee04
Copy link
Author

ssmlee04 commented Oct 10, 2016

var str = "![](https://d1rnv32spgedkm.cloudfront.net/image%2Fde3%2Fa6b%2F650%2Fe26cf40afb5ded4.jpg)

return (<Markdown>
  { str }
</Markdown>)

And I think that's basically it.

@CharlesMangwa
Copy link
Owner

CharlesMangwa commented Oct 10, 2016

You're displaying content but it doesn't correspond to the variable str which contains the URL. Maybe that's where your error come from.

@ssmlee04
Copy link
Author

It's a typo. I just edited it. Sorry..

@CharlesMangwa
Copy link
Owner

CharlesMangwa commented Oct 10, 2016

OK I got it: the issue is on my side. I have to set the resizeMode prop of the Image element, and I think it will between cover or contain.
The problem is the margin though. With cover you have no margin, but the image is cropped:
capture d ecran 2016-10-10 a 15 03 58
With the contain prop you have this huge margin depending on the size of the picture:
capture d ecran 2016-10-10 a 15 00 59
What do you think about it?

@ssmlee04
Copy link
Author

I think it's all fine depends on the use case. However do you think maybe pass something like image style into <Markdown > is a good idea?

@CharlesMangwa
Copy link
Owner

CharlesMangwa commented Oct 10, 2016

Well it wouldn't work though because resizeMode is handle by <Image /> props, not by its style. And there's no style property for this use case in RN I think.

@ssmlee04
Copy link
Author

I was kind of thinking maybe something like {resizeMode==='contain' && <Image resizeMode={'contain'} /> || <Image resizeMode={'cover'} />}.

@CharlesMangwa
Copy link
Owner

CharlesMangwa commented Oct 10, 2016

Oh ok! Sorry I didn't get you. For the time being, it seems to be a good idea: I just implemented it, you can update with a npm i react-native-simple-markdown. Tell me if it's ok!

@ssmlee04
Copy link
Author

For those images whose height is greater than width the output seems to be weird..

@CharlesMangwa
Copy link
Owner

Your image seems to be the same here:

and here:

Where's the differences plz?

@ssmlee04
Copy link
Author

ssmlee04 commented Oct 11, 2016

I think normally markdown images wouldn't have anything to do with alignments but I guess I can do something from my side anyways. :) thanks!

@CharlesMangwa
Copy link
Owner

Your welcome!

@CharlesMangwa
Copy link
Owner

Closing issue #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants