In development, use local Impress 2020 to generate outfit images

Just so we can see accurate stuff on the outfits page!
This commit is contained in:
Emi Matchu 2024-02-08 10:03:10 -08:00
parent dc44b4dbb3
commit 5d0848bf28

View file

@ -61,7 +61,12 @@ class Outfit < ApplicationRecord
OutfitImage.new(image_versions)
end
IMAGE_URL_TEMPLATE = Addressable::Template.new(
Rails.configuration.x.impress_2020.origin +
"/api/outfitImage{?id,size,updatedAt}"
)
def image_versions
if Rails.env.production?
# Now, instead of using the saved outfit to S3, we're using out the
# DTI 2020 API + CDN cache version. We use openneo-assets.net to get
# around a bug on Neopets petpages with openneo.net URLs.
@ -73,6 +78,19 @@ class Outfit < ApplicationRecord
medium: "#{base_url}/300.png",
small: "#{base_url}/150.png",
}
else
# In development, just talk to our local Impress 2020 directly.
build_url = -> size {
IMAGE_URL_TEMPLATE.expand(
id: id, size: size, updatedAt: updated_at.to_i
).to_s
}
{
large: build_url.call("600"),
medium: build_url.call("300"),
small: build_url.call("150"),
}
end
# NOTE: Below is the previous code that uses the saved outfits!
# {}.tap do |versions|