Jump to content

Recommended Posts

Posted
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'
    });
  }
}

 

Posted

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.

Posted
.imgAnexo img {
  display: block;
  margin: 0 auto;
  maxWidth: 100%;
  maxHeight: 100%;
  object-fit: contain;  
}              
  with UniImage.JSInterface do
    JSConfig('cls', ['imgAnexo']);

Work!

Posted

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...

  • Like 1
  • 1 month later...
Posted

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;  
}   


 

  • Like 1
×
×
  • Create New...