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

image source issue #24

Open
kuyagic opened this issue Mar 22, 2020 · 2 comments
Open

image source issue #24

kuyagic opened this issue Mar 22, 2020 · 2 comments

Comments

@kuyagic
Copy link

kuyagic commented Mar 22, 2020

I found when I upload an image via notion , it can be rendered correctly , but I insert an image link which the image is outside notion. it can not be rendered correctly, its url is end with undefined.

@jdetle
Copy link
Contributor

jdetle commented Apr 12, 2020

Fixed this in slug.tsx with:

 case "image":
              const { format = {} } = value;
              const {
                block_width,
                block_height,
                display_source,
                properties: image_properties,
                block_aspect_ratio
              } = format;
              const baseBlockWidth = 768;
              const roundFactor = Math.pow(10, 2);
              // calculate percentages
              const width = block_width
                ? `${Math.round(
                    (block_width / baseBlockWidth) * 100 * roundFactor
                  ) / roundFactor}%`
                : block_height || "100%";

              const useWrapper = block_aspect_ratio && !block_height;
		      const childStyle: CSSProperties = useWrapper
                ? {
                    width: "100%",
                    height: "100%",
                    border: "none",
                    position: "absolute",
                    top: 0
                  }
                : {
                    width,
                    border: "none",
                    height: block_height,
                    display: "block",
                    maxWidth: "100%"
                  };
              return (
                <img
                  key={!useWrapper ? id : undefined}
                  src={`/api/asset?assetUrl=${encodeURIComponent(
                    value.properties.source[0][0] as string
                  )}&blockId=${id}`}
                  style={childStyle}
                />
              );

@RachelHow
Copy link

RachelHow commented Sep 19, 2020

Hi, how do we implement this in ReactJS? (not Typescript)

otoyo added a commit to otoyo/notion-blog that referenced this issue Dec 19, 2020
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

3 participants