picyka Posted March 31, 2025 Posted March 31, 2025 When passing an image via url, I can't display it the same way it is when it is set in loadFromStrem DemoImg.rar
Sherzod Posted April 2, 2025 Posted April 2, 2025 4 minutes ago, picyka said: Any tips?🥺 Hello, For your case: UniImage1.ClientEvents.ExtEvents -> function afterrender(sender, eOpts) { var img = sender.getEl().down('img'); if (img) { img.setStyle({ display: 'block', margin: '0 auto', maxWidth: '100%', maxHeight: '100%', objectFit: 'contain' }); } } Â
picyka Posted April 2, 2025 Author Posted April 2, 2025 In the example it works fine, but in my real world, the image is alClient, so in the example it leaves the top image visible = false, and the bottom one puts alClient Maybe it should be aligned on the client I'm sorry for my mistake.
picyka Posted April 2, 2025 Author Posted April 2, 2025 .imgAnexo img { display: block; margin: 0 auto; maxWidth: 100%; maxHeight: 100%; object-fit: contain; } with UniImage.JSInterface do JSConfig('cls', ['imgAnexo']); Work!
Sherzod Posted April 2, 2025 Posted April 2, 2025 Yes, using CSS is a good solution. I also provided CSS-based solutions on the forum (e.g., customImg img). Why the solution above doesn't work for you — I think it's because you're loading the images dynamically... 1
likemike Posted May 21, 2025 Posted May 21, 2025 Here is a little improvement: .imgAnexo img { Â display: block; Â margin: 0 auto; Â width: 100%; Â maxHeight: 100%; Â Â position: absolute; Â top: 50%; Â left: 50%; Â transform: translate(-50%, -50%); Â object-fit: contain; Â } Â Â Â 1
Recommended Posts