Skip to content

Conversation

@NatLeung96
Copy link
Collaborator

I've added an objectPosition attribute, set to "top left", to the returned component. I believe the default behaviour is for this to be set to "center" which would explain the behaviour. I don't if it would be better for there to be an option for this?

@abigailalexander
Copy link
Collaborator

This looks good to me, I tested it in both Phoebus and CSStudio and the output image is aligned as we'd expect.
Slightly separate to above, but I also noticed that the sizing of the Image widget is slightly wrong in the web UI compared to CSStudio if stretchToFit=false.

Screenshot from 2025-03-19 15-22-48 Screenshot from 2025-03-19 15-22-32
CSStudio cs-web-lib

As you can see the CSStudio one expands to fill the full dimensions passed to the widget, so we probably aren't setting our dimensions quite right. It would be good to fix this in this PR as well.

@NatLeung96
Copy link
Collaborator Author

I have now set the width and height of the div to always be "100%". Previously, they were only being set when stretchToFit was on.

Copy link
Collaborator

@abigailalexander abigailalexander left a comment

Choose a reason for hiding this comment

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

Looks correct now, thanks. Just one minor change to make

@NatLeung96
Copy link
Collaborator Author

NatLeung96 commented Mar 20, 2025

I left that all there as I didn't want to affect the behaviour of img but actually it seems that the height and width of img can be set to 100% as well, with the only determining attribute being objectFit which is set by stretchToFit.

@NatLeung96 NatLeung96 merged commit 9f24f5f into master Mar 20, 2025
2 checks passed
@NatLeung96 NatLeung96 deleted the fix_image_stretchToFit_behaviour branch April 30, 2025 15:48
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

Successfully merging this pull request may close these issues.

Image widget stretchToFit property does not always give correct behaviour

3 participants