Change Divi Image Portfolio Grid Thumbnail Sizes

Written by Dan Mossop

The Divi Theme’s portfolio module gives you the option of displaying your projects as a series of thumbnails (grid view). To adjust the size and spacing of the images in your thumbnail grid, you can use the following CSS:

/* Set the image widths */
.et_pb_portfolio_grid .et_pb_portfolio_item,
.et_pb_portfolio_grid .column_width,
.et_pb_portfolio_grid .et_pb_portfolio_image,
.et_pb_portfolio_grid .et_pb_portfolio_image.portrait img
{
    width: 250px !important;
}
.et_pb_portfolio_grid .et_pb_portfolio_image img
{
    min-width: 250px;
}

/* Set the image heights */
.et_pb_portfolio_grid .et_pb_portfolio_image,
.et_pb_portfolio_grid .et_pb_portfolio_image.landscape img
{
    height: 250px !important;
}
.et_pb_portfolio_grid .et_pb_portfolio_image img
{
    min-height: 250px;
}

/* Set the spacing between images */
.et_pb_portfolio_grid .et_pb_portfolio_item { 
	margin-bottom:26px !important; 
	margin-right: 26px !important; 
}
.et_pb_portfolio_grid .et_pb_portfolio_item.last_in_row {
	margin-right: 0 !important;
}

It looks complex, but it’s very simple to change it to suit your needs. There are three parts. First we set the image width to 250px. Then we set the height to 250px (to get square images, in this case). Finally we set the space between adjacent images to be 26px.

The width normally available to the portfolio images is 1080px and if the images are taking up too much space the ones on the end will be pushed down to the next row. So if you want 4 images per row, make sure that 4*width + 3*spacing <= 1080px.

Craft Stunning Divi Galleries with Ease!

Bring your Divi image grids to life with Divi Gallery Booster, perfect for customizing gallery modules seamlessly. Adjust thumbnail sizes, spacing, and more to create eye-catching visual portfolios.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

30 Comments

  1. Hi. Thanks a lot for the tutorial. When using this, the images are looking very low quality like. Is there something I can do to show the images in higher quality, as it seems like it just shows the photos in the same quality as the standard 4×4 portfolio grid layout and just upscales them.

    Thanks in advance.

    Reply
    • I found out how to do it myself using the code below:
      // Begin custom image size for Portfolio Module
      add_filter( 'et_pb_portfolio_image_height', 'portfolio_size_h' );
      add_filter( 'et_pb_portfolio_image_width', 'portfolio_size_w' );

      function portfolio_size_h($height) {
      return '400';
      }

      function portfolio_size_w($width) {
      return '400';
      }

      add_image_size( 'custom-portfolio-size', 400, 400 );
      // End custom image size for Portfolio Module

      Reply
      • Hey Mikkel, glad you were able to sort it out, and thanks for sharing your solution!

        Reply
      • Mikkel, You just totally saved my bacon on a web project! Why can't we just change the quality in the module settings as surely makes sense on a lot of sites!…in the meantime, this worked a treat!

        Reply
    • Thanks, Mikkel, for sharing this php code! It worked like a charme without modifying original theme files :-)

      Reply
  2. Hi Dan,
    Thanks for this.
    But shouldn't the formula be 4*width + 3*spacing <= 1080px?
    Cheers

    Reply
    • Hey Clay, the formula was correct as the spacing was being added to the last item in the row too, though that meant the original padding amount of 25px wasn't correct (since 4*250 + 4*25 > 1080)… I've updated the code to remove the spacing on the last item in the row, so now your formula is the correct one. This means the 25px of padding if now okay, though I've bumped it up to 26px to make more full use of the space available in the row. Technically, of course, there are still a couple of extra pixels of room in the row left over since 4*250 + 3*26 is only 1078… :)

      Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.

Latest Posts

Set Custom CSS IDs for Individual Divi Accordion Items

Assigning unique CSS IDs to specific Divi Accordion items allows for precise control over styling, targeting, and linking within your page content. This ability is particularly useful when you want to apply custom designs or create anchor links to particular accordion...

Enable Swipe Navigation in the Divi Gallery Lightbox

Enabling swipe navigation in the Divi Gallery module's lightbox allows users to seamlessly browse through gallery images by swiping left or right, creating a more interactive and mobile-friendly experience. This functionality can significantly improve user engagement...

Disable Slide-In Animation for Divi Gallery Grid Images

Control how images appear in your Divi Gallery module by toggling the slide-in animation effect for grid layouts. Disabling the slide-in animation allows gallery images to load instantly and appear statically, providing a faster and distraction-free browsing...

Control Image Count Display in Divi Gallery Lightbox

Displaying or hiding the image count in the Divi Gallery module’s lightbox can help customize the user experience, depending on whether you want to give visitors an indication of gallery progress or prefer a cleaner, distraction-free view. The ability to toggle this...

Hide Gallery Image Titles in the Divi Lightbox Overlay

Displaying image titles in the lightbox overlay of the Divi Gallery module can sometimes be distracting or unnecessary, depending on your website’s design and user experience goals. Hiding these titles creates a cleaner and more focused viewing experience for visitors...

Random Posts