Skip to content

Commit

Permalink
Handle case that image details is undefined but dimensions are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Lily Hoskin committed Jul 19, 2018
1 parent 778ae72 commit d21a48c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/data/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ export const getImageDetails = (images: Images) => (
id: string,
dimensions: ?{ width: number, height: number }
): ?ImageDetails => {
if (!dimensions) {
return images[id];
const imageDetails = images[id];

// Image details might be undefined in case of unpublished image
if (!dimensions || !imageDetails) {
return imageDetails;
}

const imageDetails = images[id];
const imageUriWithResizingBehaviourParameters = `${imageDetails.uri}?w=${
dimensions.width
}&h=${dimensions.height}&fit=fill`;
Expand Down

0 comments on commit d21a48c

Please sign in to comment.