[openstreetmap/openstreetmap-website] Don't pass width/height to user menu thumbnail (PR #5036)
Anton Khorev
notifications at github.com
Thu Aug 1 02:37:50 UTC 2024
We have user image helpers:
https://github.com/openstreetmap/openstreetmap-website/blob/bbd6140f4bdc7746ecbd4d109316b2dd0b6d047f/app/helpers/user_helper.rb#L4-L41
But there's something suspicious in their code. `options` has different keys merged in different places: sometimes it's `:size`, sometimes it's `:width`/`:height`. Are we supposed to be able to pass our own size to the helpers? If yes, which keys should we use?
Easier question is *do we actually try to pass our own size*? There's only one place where we do, the one I remove in this pull request. Does it have any effect, given that helpers sometimes overwrite it? There are different code paths depending on the type of the image. The only path that uses those `:width => 25, :height => 25` is unprocessed attached image, when this overwrite doesn't happen because we don't yet know the actual image size:
https://github.com/openstreetmap/openstreetmap-website/blob/bbd6140f4bdc7746ecbd4d109316b2dd0b6d047f/app/helpers/user_helper.rb#L91-L92
But we don't really need to set this image size because we override it with css:
https://github.com/openstreetmap/openstreetmap-website/blob/bbd6140f4bdc7746ecbd4d109316b2dd0b6d047f/app/assets/stylesheets/common.scss#L789-L803
It's easier not to pass image sizes to helpers. We won't have then to think whether it's `:size`, `:width`/`:height` or [all of them](https://github.com/openstreetmap/openstreetmap-website/commit/4ef7b2c651e20f147719f3ff0bec0dc6bfd7ea2c).
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/5036
-- Commit Summary --
* Don't pass width/height to user menu thumbnail
-- File Changes --
M app/views/layouts/_header.html.erb (2)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/5036.patch
https://github.com/openstreetmap/openstreetmap-website/pull/5036.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5036
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5036 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240731/e02414f0/attachment.htm>
More information about the rails-dev
mailing list