Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #17692

    Hi is it possible to randomise the order of the masonry gallery/grid?

    or

    at least have the lastest item shown up first?

    at the moment it display the oldest item first, i just would like the site to look fresh. even when i upload new images, no one will know about them unless they scroll to the bottom.

    i tried these other coding, but they don’t seem to work for the mansory grid, worked well for porfolio.

    http://www.kriesi.at/support/topic/portfolio-sort-order-reverse-chronological-1

    sorry but my coding skills are next to none.

    thanks in advance

    #96475

    Unfortunately this is not (easily) possible because the masonry gallery loads the data via ajax and if you randomize the slides you’ll get many duplicate images (in the worst case the same images will be loaded over and over again when the user scrolls just because the “random” order selects them). However if you don’t care about this drawback you can replace following code in includes/helper-slideshow.php:

    function retrieve_post_images()
    {
    global $avia_config;
    $unqiue_id = avia_post_meta($this->id, 'gallery_image');
    $attachment_holder = avia_get_post_by_title( "avia_smart-gallery-of-post-".$unqiue_id);

    if(empty($attachment_holder['ID'])) return;

    $attachments = get_children(array('post_parent' => $attachment_holder['ID'],
    'post_status' => 'inherit',
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'order' => 'ASC',
    'orderby' => 'menu_order ID'));

    with:

    function retrieve_post_images()
    {
    global $avia_config;
    $unqiue_id = avia_post_meta($this->id, 'gallery_image');
    $attachment_holder = avia_get_post_by_title( "avia_smart-gallery-of-post-".$unqiue_id);

    if(empty($attachment_holder['ID'])) return;

    $attachments = get_children(array('post_parent' => $attachment_holder['ID'],
    'post_status' => 'inherit',
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'orderby' => 'rand'));

    Otherwise you need some code which checks for duplicates and removes them from the ajax response – however this requires some work and a skilled coder/freelancer.

    #96476

    thanks for your help!

    if that is the case would it be easier or possible just to reverse the order? to have the lastest uploads appear at the top of the page rather than at the bottom?

    any chance you could provide the code for that?

    many thanks!

    #96477

    Hey!

    Yes, in this case stick with the original code and replace:

    'order' => 'ASC',

    with:

    'order' => 'DESC',

    Regards,

    Peter

    #96478

    Hi Peter

    i had a look at the coding under

    loop-masonry.php

    and i can not find the above, the code in this area is as below, am i in the wrong section? i did the above for loop-portfolio.php as well as the coding for avia_framwork.php and all seem to work fine, just that i can’t find the same coding under loop.masonry.php

    <?php

    global $avia_config;

    $items_per_page = 8;

    $gallery = new masonry_gallery(‘masonry’);

    $items = $gallery->display($items_per_page);

    $pagination = avia_pagination($gallery->pagecount());

    if(!post_password_required())

    {

    if($items)

    {

    $loading_text = __(‘Loading more images’,'avia_framework’);

    $loading_stop = __(‘No more images available’,'avia_framework’);

    $loading_img = AVIA_BASE_URL.”/images/skin-minimal/loading.gif”;

    echo “<div class=’masonry-content-area’ data-loadingtext=’$loading_text’ data-loadingstop=’$loading_stop’ data-loadingimg=’$loading_img’ >”;

    echo $items;

    echo “</div>”;

    echo “<div class=’masonry-pagination’>”;

    if($pagination) { echo $pagination; } else { echo “<div class=’pagination’></div>”; }

    echo “</div>”;

    }

    }

    #96479

    Hey!

    The code can be found in flashlight/includes/helper-slideshow.php.

    Best regards,

    Peter

    #96480

    thanks Champ!

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Masonry Gallery /Grid order?’ is closed to new replies.