Skip Navigation

[Resolved] Gallery images fit full 1 0r 2 0r 3 0r 4 fit inline full width

This support ticket is created 4 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 8 replies, has 2 voices.

Last updated by Christian Cox 4 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1842395
image.jpg

Hello

1 - I am trying to make it so this page - hidden link - if only one / two / three image are added it fits the whole container lengthwise and matches the same width as the 4 images in a row. (see attached)

2 - Can I have a separate view for mobile and desktop on the same page. it tells me "It is not supported" what is the best way around this

Thanks, Alex

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/different-views-for-mobile-and-desktop/

#1842563

Hello, I'm moving your login information out of your message for your security. If you'd like to provide logins in the future, a support team member can activate private reply fields so you can share securely. I'm reviewing your questions and will respond shortly.

#1842677
conditional-config.png

1 - I am trying to make it so this page - hidden link - if only one / two / three image are added it fits the whole container lengthwise and matches the same width as the 4 images in a row. (see attached)
At this time, it is not currently possible to achieve exactly what you have described here for two reasons:
- The gallery block is not configured to allow variable column counts based on the number of items being displayed.
- I was trying out a workaround using conditionals, but encountered what I believe is a bug in the Grid block: when I add more than one Grid Gallery block to the WordPress Archive editor, I cannot adjust the column count for each Gallery block individually. Any change to one of the column count settings effects all the column count settings. I will ask my 2nd tier team to investigate this and see if there is a better solution available, then give you an update.

The workaround I have in mind uses a custom shortcode and a series of conditional blocks. Here's how it would work.
1. You must add the custom shortcode to your child theme's functions.php file or to a custom code snippet in Toolset > Settings > Custom Code. Here is the snippet:

// shortcode to count number of repeating field instances
add_shortcode( 'count-repeats', 'count_repeat_func' );
function count_repeat_func($atts) {
    return sizeof(get_post_meta( get_the_ID(), 'wpcf-' . $atts['field'], false ));
}

2. You must register this shortcode to make it available for use in conditional blocks. Go to Toolset > Settings > Frontend Content and enter count-repeats in the Third-party shortcode arguments section.
3. You must refresh the WordPress Archive editor page in wp-admin if it is already open.
4. You can now add a conditional block in your WordPress Archive editor page.
5. Click "Add new conditions" to add a condition, which will determine whether or not the contents of the Conditional Block are displayed.
6. Select Custom Shortcode in the first input field, then select the count-repeats shortcode in the next input. In the third input, type this code:

field="your-field-slug"

7. Replace your-field-slug with the slug of your repeating image field, which you can find in Toolset > Custom Fields > Post Fields.
8. In the right side of the conditional equation, enter the static value 1. See attached conditional-config.png for an example of how it should look (for example my field slug is "book-rept-img-1") once you've completed these steps.
9. Save the conditional block and drag your existing gallery block so it is nested inside the conditional block, or create a new gallery block directly inside the conditional block.
10. Select the gallery block if necessary by clicking it or using the Block Navigator. Once selected, choose the gallery style that appears first, the "grid" style. If you have not selected a dynamic source, select your repeating image field there. Finally, adjust the number of columns in the grid to be 1.
10. Preview the page. If only one image is saved in the repeating image field, you should see a gallery appear with a full-width image. You should see no other galleries for now. We will add those next.
11. Repeat steps 4 - 9 three times, adding new conditional blocks one below another in the block editor. Each time you add a new conditional block, adjust the number in the right side of the conditional equation as well as the number of columns in each grid block so you have conditionals that test for the values 1, 2, 3, and 4, corresponding to gallery grids with 1, 2, 3 or 4 columns respectively.
12. When you preview the page, you should see different image widths depending on the number of images saved for each post.

Let me reach out to my 2nd tier support team to confirm this issue with the Column Count settings in multiple gallery blocks and give you an update.

#1844923

My 2nd tier team has asked the developers for more information about this, and I will keep you posted here.

#1847817

Our developers have confirmed the problem and will address it in a future update of the software. After some experimentation we were able to determine that it is possible to work around the gallery grid column issue by saving the post and refreshing the post editor screen. Then you can set a different value for gallery grid columns in different blocks. This workaround might work until we can get the problem addressed more effectively in a future release.

#1848249
toolset screenshot.jpg

Thankyou for this,

We came up with a workaround for the time being by adding 4 separate gallery fields in the backend of a listing and then only filling in the relevant ones.

#1848527

Okay thanks for the update. I'll let you know once this issue is addressed in the Blocks plugin, then the workaround can be abandoned.

#1849507

Brilliant, Please just let me know when that option is available.

#1921725

This issue has been resolved in the latest versions of the Blocks and Views plugin.