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

Only works with square images #64

Open
satyavh opened this issue Aug 31, 2017 · 2 comments
Open

Only works with square images #64

satyavh opened this issue Aug 31, 2017 · 2 comments

Comments

@satyavh
Copy link

satyavh commented Aug 31, 2017

Any other image format stretches/deforms the image. Solution is to generate an avatar with a background-image set to cover.

@cathal-killeen
Copy link

I am looking for this feature too. Would be nice to have

@lightsinthesky
Copy link

 _renderAsDiv() {
    const { className, round, unstyled, name, value } = this.props;
    const { internal } = this.state;
    const size = parseSize(this.props.size);
    const alt = name || value;

    const imageStyle = unstyled
      ? null
      : {
          maxWidth: "100%",
          width: size.str,
          height: size.str,
          borderRadius: round === true ? "100%" : round
        };

    return (
      <div
        className={className + " sb-avatar__image"}
        width={size.str}
        height={size.str}
        style={imageStyle}
        alt={alt}
        onError={internal && internal.fetch}
      >
        <div
          style={{
            width: "100%",
            height: "100%",
            backgroundSize: "cover",
            backgroundImage: `url(${this.state.src})`,
            backgroundPosition: "50% 50%",
            borderRadius: round === true ? "100%" : round
          }}
        />
      </div>
    );
  }

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

No branches or pull requests

5 participants