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

Show image size on view page #25884

Merged
merged 9 commits into from
Jul 31, 2023
Merged

Show image size on view page #25884

merged 9 commits into from
Jul 31, 2023

Conversation

JakobDev
Copy link
Contributor

This simply shows the Image size on the view page. This is useful, if you search a image with a specific size.

grafik

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 14, 2023
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 14, 2023
@silverwind
Copy link
Member

Given the style of these file infos, they don't had a label so far, so I think just 32x32 would be better.

@lunny lunny added the topic/ui Change the appearance of the Gitea UI label Jul 14, 2023
@lunny lunny added this to the 1.21.0 milestone Jul 14, 2023
routers/web/repo/view.go Outdated Show resolved Hide resolved
routers/web/repo/view.go Outdated Show resolved Hide resolved
@JakobDev
Copy link
Contributor Author

JakobDev commented Jul 14, 2023

Given the style of these file infos, they don't had a label so far, so I think just 32x32 would be better.

I just want to make this clear, that these numbers are the size of the image, so nobody is confused. On things like 1.0 KiB everyone knows what this mean.

@silverwind
Copy link
Member

I think it's obvious anyways. We could add label tooltips to these items if we really want to show a label.

@JakobDev
Copy link
Contributor Author

I think it's obvious anyways.

I'm not sure if that's obvious for anybody. I think explicit is better than implicit.

We could add label tooltips to these items if we really want to show a label.

This is the only entry in this list that has a Popup, so this would maybe be a little weird.

@silverwind
Copy link
Member

silverwind commented Jul 14, 2023

This is the only entry in this list that has a Popup, so this would maybe be a little weird.

We can add label tooltips to all of them. I could likely push that into this PR.

@silverwind
Copy link
Member

silverwind commented Jul 14, 2023

Also "Size" is ambiguous anyways as we have two sizes: image size and file size.

@delvh
Copy link
Member

delvh commented Jul 14, 2023

Please run make fmt

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 14, 2023
@JakobDev
Copy link
Contributor Author

We can add label tooltips to all of them. I could likely push that into this PR.

You can do that, if you want, but I thnk adding Tooltips for others is a bit out of touch for this PR.

Also "Size" is ambiguous anyways as we have two sizes: image size and file size.

Fair point. So it's better to use image size.

Please run make fmt

Done

@mrsdizzie
Copy link
Member

If there is a label / tooltip it should use Dimensions and not Size when referring to pixels (which also removes any ambiguity around what size)

Copy link
Member

@denyskon denyskon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach is nice - we just need to take a look at that file header on mobile....

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 14, 2023
Copy link
Member

@techknowlogick techknowlogick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking per @mrsdizzie's suggestion of using Dimension vs Size

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Jul 15, 2023
@silverwind
Copy link
Member

silverwind commented Jul 16, 2023

I still prefer it without a label, it just does not fit to add a label in a list that is only values. Take for example code header, no labels anywhere:

2 lines | 19 B | Plaintext

@JakobDev
Copy link
Contributor Author

It says 2 lines and not just 2.

@silverwind
Copy link
Member

By that notion, you would have to put "pixels", but it's a silly discussion.

@denyskon
Copy link
Member

Let's just say 1920x1080 px, that should be clear to everyone.

@JakobDev
Copy link
Contributor Author

I would agree with px. Did this need a translation?

@denyskon
Copy link
Member

I don't think so....

if err == nil {
// There are Image formats go can't decode
// Instead of throwing an error in that case, we show the size only when we can decode
ctx.Data["ImageSize"] = fmt.Sprintf("%dx%dpx", img.Width, img.Height)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ' !fInfo.st.IsSvgImage()' not svg?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

svg is text-based instead of binary, and vector-based instead of line-by-line, so it doesn't really have a "size".
It is only limited by the view box that can be arbitrarily scaled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely correct. SVGs can have height and width, and if they are absent, the size of the viewport is used IIRC. If even that is absent, browser will use 300×150 IIRC. Still I guess it's enough if this PR handles only raster images for now.

@denyskon
Copy link
Member

@silverwind & @techknowlogick

Would you agree with px? If so, could we unblock this PR?

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Jul 29, 2023
@denyskon denyskon requested a review from silverwind July 29, 2023 22:03
@silverwind
Copy link
Member

silverwind commented Jul 30, 2023

1920x1080px seems better than with the "Image Size: " prefix, yes.

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 30, 2023
@silverwind silverwind enabled auto-merge (squash) July 30, 2023 23:30
@techknowlogick techknowlogick dismissed their stale review July 30, 2023 23:38

Dismiss my stale review

@silverwind silverwind merged commit aba9096 into go-gitea:main Jul 31, 2023
23 checks passed
@JakobDev JakobDev deleted the showsize branch July 31, 2023 06:06
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 31, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 31, 2023
* upstream/main: (26 commits)
  Add 'Show on a map' button to Location in profile, fix layout (go-gitea#26214)
  Use shared template for webhook icons (go-gitea#26242)
  Reduce margins on user settings page, introduce `flex-container` (go-gitea#26046)
  Refactor and enhance issue indexer to support both searching, filtering and paging (go-gitea#26012)
  Show image size on view page (go-gitea#25884)
  Fix pull request check list is limited (go-gitea#26179)
  Fix API leaking Usermail if not logged in (go-gitea#25097)
  [skip ci] Updated licenses and gitignores
  Fix typo in metadata (go-gitea#26207)
  Update js and py dependencies (go-gitea#26243)
  De-emphasize issue sidebar buttons (go-gitea#26171)
  Don't autosize textarea in diff view (go-gitea#26233)
  Add `/public/assets` to `.ignore` (go-gitea#26232)
  Fix attachment clipboard copy on insecure origin (go-gitea#26224)
  Fix commit compare style (go-gitea#26209)
  Fix unable to display individual-level project (go-gitea#26198)
  Fix access check for org-level project (go-gitea#26182)
  Fixed incorrect locale references (go-gitea#26218)
  Use calendar icon for `Joined on...` in profiles (go-gitea#26215)
  Add changelog for 1.20.2 (go-gitea#26208)
  ...
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. topic/ui Change the appearance of the Gitea UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants