Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: mdb-image-modal - how to set 3 images to 2 images in a row

cjj2009 free asked 5 years ago


Expected behavior show one image in a row Actual behavior can not to change this for Resources (screenshots, code snippets etc.) enter image description here


Bartosz Termena staff answered 5 years ago


Dear @cjj2009

Thank you for the info. We will consider adding a new functionality to change the number of images in the column. As a workaround this problem, I am providing my code below:

 import { ImageModalComponent } from 'your_path'';
 @ViewChild('ImageModalComponent', { static: true }) ImageModalComponent: ImageModalComponent;
  imagesBasic = [
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(117).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(117).jpg',
      description: 'Image 1',
    },
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(98).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(98).jpg',
      description: 'Image 2',
    },
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(131).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(131).jpg',
      description: 'Image 3',
    },
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(123).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(123).jpg',
      description: 'Image 4',
    },
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(118).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(118).jpg',
      description: 'Image 5',
    },
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(128).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(128).jpg',
      description: 'Image 6',
    },
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(132).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(132).jpg',
      description: 'Image 7',
    },
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(115).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(115).jpg',
      description: 'Image 8',
    },
    {
      img: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(133).jpg',
      thumb: 'https://mdbootstrap.com/img/Photos/Horizontal/Nature/12-col/img%20(133).jpg',
      description: 'Image 9',
    },
  ];
  constructor(private renderer: Renderer2) {}
  ngAfterViewInit() {
    for (const child of this.ImageModalComponent.element.nativeElement.children) {
      for (const col of child.children) {
        if (!col.classList.contains('ng-gallery-content') && !col.classList.contains('top-bar')) {
          this.renderer.removeClass(col, 'col-md-4');

          this.renderer.addClass(col, 'col-md-6');
        }
      }
    }
  }

HTML:

<div class="container">
  <div class="row">
    <mdb-image-modal
      #ImageModalComponent
      [modalImages]="imagesBasic"
      type="no-margin"
    ></mdb-image-modal>
  </div>
</div>

cjj2009 free commented 5 years ago

Hi,

Thanks for you reply and I think it looks hard to me to solved this issue after I refer your code this time.

Regards, James


Bartosz Termena staff commented 5 years ago

Dear @cjj2009

I assure you that we will add the possibility to change the number of images in the column in the near future.

I will let you know about that.

Best Regards, Bartosz.


cjj2009 free commented 5 years ago

Many thanks! James


cjj2009 free commented 5 years ago

Hi, Would you like the tell me how to set below statement about 'your_path'? import { ImageModalComponent } from 'your_path'';

Thanks, James


Bartosz Termena staff commented 5 years ago

Hi!

Try import { ImageModalComponent } from 'ng-uikit-pro-standard';

Best Regards, Bartosz.


cjj2009 free commented 5 years ago

Hi Bartosz,

It is working now for the 2 images in each row!

Many Thanks for you help! :)

Regards, James


royax1988 free answered 4 years ago


hi is it possible to auto adjust portrait photos as well? right now if i have 1 portrait and 2 landscape photos in 1 row - it would destroy the display.


Arkadiusz Idzikowski staff commented 4 years ago

Unfortunately currently it is not possible, we will take a closer look at this problem.


royax1988 free commented 4 years ago

but is it possible to put some styling like "object-fit: contain" so that it adjust accordingly.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 8.3.1
  • Device: laptop
  • Browser: Chrome
  • OS: windows 10
  • Provided sample code: No
  • Provided link: No
Tags