Skip to content

Commit

Permalink
Use a placeholder image from asset-manager
Browse files Browse the repository at this point in the history
In the past this linked to an image served by Whitehall, but because of
the way Rails generates hashes for assets, we can't guarantee that this
URL will always exist. This hasn't been a problem in the past because
we've been able to put an unhashed version of the image on the Whitehall
machines, but since moving to AWS the machines can be recreated at any
moment and won't have the file.

To solve this problem I've uploaded the file to Asset Manager and we can
link to that instead. Ideally, we wouldn't depend on a file in a
different application, but this solves the problem for now.
  • Loading branch information
thomasleese committed Mar 2, 2020
1 parent 288996c commit 6229870
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/presenters/content_item/news_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def default_news_image
end

def placeholder_image
{ "url" => "https://assets.publishing.service.gov.uk/government/assets/placeholder.jpg" }
# this image has been uploaded to asset-manager
{ "url" => "https://assets.publishing.service.gov.uk/media/5e59279b86650c53b2cefbfe/placeholder.jpg" }
end
end
end
2 changes: 1 addition & 1 deletion test/presenters/content_item/news_image_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def initialize

test "presents a placeholder image if document has no image or default news image" do
item = DummyContentItem.new
placeholder_image = { "url" => "https://assets.publishing.service.gov.uk/government/assets/placeholder.jpg" }
placeholder_image = { "url" => "https://assets.publishing.service.gov.uk/media/5e59279b86650c53b2cefbfe/placeholder.jpg" }

assert_equal placeholder_image, item.image
end
Expand Down

0 comments on commit 6229870

Please sign in to comment.