Skip to content

Commit

Permalink
fix: images url (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
Melisa Anabella Rossi authored Dec 6, 2023
1 parent 7d7cdda commit 350a948
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/Place/PlaceDescription/PlaceDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TrackingPlacesSearchContext } from "../../../context/TrackingContext"
import { AggregatePlaceAttributes } from "../../../entities/Place/types"
import { explorerUrl } from "../../../entities/Place/utils"
import { SegmentPlace } from "../../../modules/segment"
import { getImageUrl } from "../../../utils/image"
import FavoriteBox from "../../Button/FavoriteBox"
import JumpInPositionButton from "../../Button/JumpInPositionButton"
import ShareBox from "../../Button/ShareBox"
Expand Down Expand Up @@ -60,7 +61,7 @@ export default React.memo(function PlaceDescription(
style={
!loading && place?.image
? {
backgroundImage: `url(${place.image})`,
backgroundImage: `url(${getImageUrl(place.image)})`,
}
: {}
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/Place/PlaceFeatured/PlaceFeatured.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AggregatePlaceAttributes } from "../../../entities/Place/types"
import { explorerUrl } from "../../../entities/Place/utils"
import locations from "../../../modules/locations"
import { SegmentPlace } from "../../../modules/segment"
import { getImageUrl } from "../../../utils/image"
import UserCount from "../../Label/UserCount/UserCount"

import "./PlaceFeatured.css"
Expand All @@ -37,7 +38,9 @@ export default React.memo(function PlaceFeatured(props: PlaceFeaturedProps) {
<div
className={TokenList.join(["place-featured", loading && "loading"])}
style={{
backgroundImage: `url("${item.highlighted_image || item.image}")`,
backgroundImage: `url("${getImageUrl(
item.highlighted_image || item.image
)}")`,
}}
>
<div className="place-featured__overlay" />
Expand Down
3 changes: 2 additions & 1 deletion src/components/World/WorldDescription/WorldDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TokenList from "decentraland-gatsby/dist/utils/dom/TokenList"
import { AggregatePlaceAttributes } from "../../../entities/Place/types"
import { explorerUrl } from "../../../entities/Place/utils"
import { SegmentPlace } from "../../../modules/segment"
import { getImageUrl } from "../../../utils/image"
import FavoriteBox from "../../Button/FavoriteBox"
import JumpInPositionButton from "../../Button/JumpInPositionButton"
import ShareBox from "../../Button/ShareBox"
Expand Down Expand Up @@ -58,7 +59,7 @@ export default React.memo(function WorldDescription(
style={
!loading && world?.image
? {
backgroundImage: `url(${world.image})`,
backgroundImage: `url(${getImageUrl(world.image)})`,
}
: {}
}
Expand Down
8 changes: 8 additions & 0 deletions src/utils/image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import env from "decentraland-gatsby/dist/utils/env"

export function getImageUrl(imageUrl?: string | null) {
if (env("NEW_ROLLOUT") && imageUrl && imageUrl.startsWith("/")) {
return `/places${imageUrl}`
}
return imageUrl
}

0 comments on commit 350a948

Please sign in to comment.