Zyad A
02/13/2023, 5:17 PMjakemumu
02/13/2023, 5:33 PM:small
in the function signature? -- you should be able to specify :original
to get the original file you uploaded. The images get automatically post processed and minified to make them look good for say a thumbnail, but if you use the thumbnail to render a large image, it will look very poor. I tend to just pre process myself and use :original
in the codeJared Norman
Zyad A
02/13/2023, 5:51 PM# frozen_string_literal: true
class ImageComponent < ViewComponent::Base
attr_reader :image, :size, :classes, :options
def initialize(local_assigns = {})
@image = local_assigns.delete(:image)
@size = local_assigns.delete(:size) { :mini }
@classes = local_assigns.delete(:classes)
@options = local_assigns
end
def call
if image
image_tag image.url(size), default_options.merge(options)
else
content_tag :div, nil, class: ['image-placeholder', size].join(' ')
end
end
private
def default_options
{ alt: image.alt, class: classes }
end
end
Chris Todorov
02/13/2023, 6:32 PMsize
to that ImageComponent
and adjust according to your needs. Based on this partial it looks like it’s using the :product
size https://github.com/solidusio/solidus_starter_frontend/blob/15e338897e83d10722521ba[…]e693f51b36/templates/app/views/products/_product_image.html.erb
that is defined through configuration and you can change that in your app https://github.com/solidusio/solidus/blob/6a732e2711d834656ed1d9072abf0a8130f0c265/core/lib/spree/app_configuration.rb#L541-L544Chris Todorov
02/13/2023, 6:34 PMChris Todorov
02/13/2023, 6:50 PMChris Todorov
02/13/2023, 6:51 PMZyad A
02/14/2023, 7:50 AMChris Todorov
02/14/2023, 6:07 PMChris Todorov
02/14/2023, 6:07 PMZyad A
02/15/2023, 8:49 AMProcessing by Spree::Admin::ImagesController#create as JS
Parameters: {"image"=>{"attachment"=>#<ActionDispatch::Http::UploadedFile:0x00007f2f14770868 @tempfile=#<Tempfile:/tmp/RackMultipart20230215-2-yglpp0.jpeg>, @original_filename="a1.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"image[attachment]\"; filename=\"a1.jpeg\"\r\nContent-Type: image/jpeg\r\n">, "viewable_id"=>"49"}, "upload_id"=>"c8", "product_id"=>"test"}
the issue is that after that, several more versions are created at different sizes and resolutions
there is repeated log of (same key)
[ActiveStorage::AnalyzeJob] [3e884de1-f1ea-4fd1-9e46-e55ee326cd00] [Aws::S3::Client 200 0.085494 0 retries] head_object(bucket:"permanence-bucket",key:"dbgbxqtkvw70p773u2kgnedr4u6q")
followed ultimately by new object creation
[Aws::S3::Client 200 0.163308 0 retries] put_object(body:#<Tempfile:/tmp/image_processing20230215-2-iy3bu0.jpeg>,content_md5:"9L+s+mwcBVMlPUxdDZngXw==",content_type:"image/jpeg",content_disposition:nil,metadata:{},bucket:"permanence-bucket",key:"o8yv5zkmwzj99tz014noepb9ij6f")
Working to figure out why this is happening, any suggestions would be awesome!Zyad A
02/15/2023, 4:20 PMChris Todorov
02/15/2023, 6:40 PMZyad A
02/15/2023, 6:48 PMZyad A
02/15/2023, 6:59 PMChris Todorov
02/15/2023, 7:00 PMChris Todorov
02/15/2023, 7:00 PMChris Todorov
02/15/2023, 7:01 PMZyad A
02/15/2023, 7:07 PMconfig.active_storage.service_urls_expire_in = false
Chris Todorov
02/15/2023, 7:15 PMconfig/storage.yml
per service. This is the related issue https://github.com/rails/rails/pull/36729Chris Todorov
02/15/2023, 7:16 PMZyad A
02/15/2023, 7:25 PMChris Todorov
02/15/2023, 7:26 PM