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

Html component does not show image if linked #408

Open
helloagain-dev opened this issue Aug 21, 2018 · 0 comments
Open

Html component does not show image if linked #408

helloagain-dev opened this issue Aug 21, 2018 · 0 comments

Comments

@helloagain-dev
Copy link
Contributor

We use the Html component in a custom extension which is based on the About extension.

The issue we face now for a while is that an image is not rendered if it is wrapped in an anchor:

<a href="google.com"><img src="https://www.google.at/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"></a>

I did some debugging and found out the the issue is caused because the ImageBackground never receives a height correctly. Only through the source attribute which is not used for this component.
It needs to receive it via the style attribute, but that is never passed from any HTML code. At least I couldn't find a way to tell the img tag to have a proper height, neither through height attribute nor height style.

To illustrate the issue, below is some code that properly passes the imageHeight to the ImageBackground (node_modules/@shoutem/ui/html/components/Image.js).

    let newProps = _.merge(this.props, {
      style: {
        width: imageWidth,
        height: imageHeight
      }
    })

    // Showing image as background, can't be opened (zoomed).
    return (
      <ImageBackground
        {...newProps}
        source={{ width: imageWidth, height: imageHeight, ...source }}
      >
        {children}
      </ImageBackground>
    );

In general it is an issue that I cannot pass a width or height, but 300px is hardcoded. The best solution would be if I the width/height passed to the img tag is used properly.

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

1 participant