Tagged: masonry, Masonry Gallery, perfect grid
-
AuthorPosts
-
September 6, 2023 at 11:46 pm #1418309
Hi there
I’m using the Masonry element with “Perfect Grid” setting to display a site’s blog posts. The problem is, if the title or description (or both) of a post are too long, it resizes the image, making it look like it’s no longer a “Perfect Grid” (even though technically it is).
Ideally I’d like the images to have a fixed size/shape, regardless of the screen resolution, and simply (dynamically) modify the length of the description, in order to fit everything and remain a “perfect grid”.
Is this possible?
September 8, 2023 at 3:25 pm #1418480Hey adapt,
Thank you for the inquiry.
You might be able to use the avf_masonry_entry_content filter to adjust the length of the content. Usage example can be found in the following threads.
// https://kriesi.at/support/topic/show-category-in-masonry-gallery-with-link-to-overview-posts-in-that-category/#post-1362994
// https://kriesi.at/support/topic/how-to-remove-a-section-not-visible-on-edit-page-and-not-in-the-footer/#post-1369818Please provide the site URL in the private field so that we can check the Masonry element.
Best regards,
IsmaelSeptember 9, 2023 at 1:56 am #1418518Sure thing Ismael, I’ve included the link to the page below.
In the meantime I’ll check out the links you provided – thank you!
September 10, 2023 at 10:57 pm #1418696Hi,
Thanks for the link to your page, I checked all of the masonry items and they all seemed to be the same size. Did you manually adjust the titles and content or did you already solve the issue?
Perhaps you could try this css, it limits the title content area to a specific height and hides the overflow:.av-inner-masonry-content-pos, .av-inner-masonry-content-pos-content { max-height: 152px; overflow: hidden; }
currently all of the items fit in the 152px height, and I tested with 140px and it worked hiding the extra text. You can try this if you still need a solution.
Best regards,
MikeSeptember 11, 2023 at 1:24 am #1418703That’s perfect Mike – that’s exactly what I was looking for.
Thank you!
September 11, 2023 at 3:11 am #1418705Actually, is there a way to dynamically display a “…” at the end of the text, if it’s one of the ones that is too long and gets cut off?
Just so the user can clearly see it’s “continued”, rather than just cutting it short?
September 11, 2023 at 4:51 am #1418710Hi,
Thank you for the update.
You can try this filter in the functions.php file to limit the masonry content to 50 characters.
add_filter("avf_masonry_entry_content", function($content) { $limit = 50; if (strlen($content) > $limit) { $content = substr($content, 0, $limit); $content .= '...'; } return $content; }, 10, 1);
You may need to remove the css modification temporarily and adjust the limit if necessary.
Best regards,
IsmaelSeptember 12, 2023 at 6:24 am #1418826Thanks Ismael, that’s an excellent solution. The one Mike provided works for now, so I’ll just stick with that, but if we need to make adjustments in the future, I’ll revert to this suggestion, as it’s probably the cleanest.
Thanks!
September 12, 2023 at 6:59 am #1418830 -
AuthorPosts
- The topic ‘Restrict Masonry gallery title & description’ is closed to new replies.