Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

either width or height must be specified #5649

Open
SamuelBonilla opened this issue Feb 7, 2024 · 8 comments
Open

either width or height must be specified #5649

SamuelBonilla opened this issue Feb 7, 2024 · 8 comments

Comments

@SamuelBonilla
Copy link

SamuelBonilla commented Feb 7, 2024

Solidus Version:

gem "solidus", "~> 4.3"

gem "solidus_admin", ">= 0.2"

gem "solidus_auth_devise", "~> 2.5"

To Reproduce
Steps to reproduce the behavior:

  1. Set up the Solidus environment using

bundle add solidus
bin/rails g solidus:install

  1. Within the Rails application, navigate to the relevant view that is calling the image_tag helper method.
  2. Attempt to render an image without specifying either a width or height in the size parameter.
  3. See error: "either width or height must be specified".

Current behavior
When attempting to use image_tag helper without specifying either a width or height in the size parameter, an error is produced stating that either width or height must be specified. This occurs even though the application's logic should provide a default or extract the size to ensure at least one dimension is present.

Extracted source (around line #15):

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

Expected behavior
The application should either provide a default size if none is given or handle the absence of dimensions without raising an error, allowing for graceful degradation or a fallback to a default placeholder.

Screenshots

image

Desktop (please complete the following information):

  • OS: macOS 13.2.1 (22D68)
  • Browser: Chrome
  • Version: Last Version

Additional context

  • Ruby version: 3.2.2
  • Rails version: 7.0
  • The issue presents a problem in a Rails view where the image_tag helper is not handling the absence of a specified size gracefully. It seems to be an oversight in either the application's code or a library that the application is using.
@mitvitaminen
Copy link

mitvitaminen commented Feb 8, 2024

bump, same error here

using Desktop (please complete the following information):

OS: linux arch latest
Browser: firefox
Version: Last Version

Additional context

Ruby version: 3.0.0
Rails version: 7.1.3
The issue presents a problem in a Rails view where the image_tag helper is not handling the absence of a specified size gracefully. It seems to be an oversight in either the application's code or a library that the application is using.

Comments:
I have to say that I have a lot of errors in the generated files right after installation (more then 190+) using eclipse ide latest version

@mitvitaminen
Copy link

Alright this issue resolved itself once I updated ruby to 3.3.0 with rvm @SamuelBonilla

@nvandoorn
Copy link
Contributor

Hey @SamuelBonilla I had a quick look at this issue and I believe what you describe is more related to the image_processing gem and the underlying VIPS library: https://github.com/janko/image_processing/blob/c20d147765a064840d4cad0ff6b7ebcfe65eeaa8/lib/image_processing/vips.rb#L153

@krnwrks
Copy link

krnwrks commented Mar 7, 2024

bump, same problem after fresh installation

@maikis
Copy link

maikis commented Mar 20, 2024

Same problem here. Ruby 3.3.0. Looks like seeded demo product images causes this failure. With all of the demo products removed and new products added everything works fine. Did not dig deeper yet to see what's wrong - the images itself are loading fine and are visible in admin backend.

@asfour75
Copy link

This is weird ..

inside file app/components/image_component.rb I just replaced the size variable with constant when I was debugging.

image_tag image.url(size), default_options.merge(options)
To
image_tag image.url(:small), default_options.merge(options)

And everything worked fine !!

@jarednorman
Copy link
Member

@nvandoorn The height/width should be coming from our code though, right? That's why @asfour75's change fixes it.

@asfour75
Copy link

asfour75 commented Mar 24, 2024

@nvandoorn The height/width should be coming from our code though, right? That's why @asfour75's change fixes it.

After further debugging .. the size variable passed to image_component.rb:
:small, "product", :full

While this line:
image_tag image.url(size), default_options.merge(options)

size variable can accept only:
(mini: '48x48>', small: '100x100>', product: '240x240>', large: '600x600)

So I changed any value with 'big' -> 'product' and 'full' -> 'large'

Maybe the error message was misleading ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants