WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: File Gallery] featured images

[Resolved] [Plugin: File Gallery] featured images

  • Hello,

    I have several images attached to a post. What I would like to do is to create a custom html for all the images in a way that featured image always appears first and is of a bigger size than all other images.

    I’ve noticed that when you mark an image in File Gallery as featured it doesn’t necessarily appears first.

    I’m using the following code within a template (see below), so that I can go through each image and create custom html for them.

    How can I make sure that a featured image appears first and is of different size, and potentially have a bit different html? Do I need to make 2 separate calls to file_gallery_shortcode function?

    $images_args = array(
      'order' => 'ASC',
      'orderby' => '',
      'id' => $post->ID,
      'columns' => 3,
      'size' => 'thumbnail',
      'link' => 'attachment',
      'linkclass' => '',
      'imageclass' => '',
      'rel' => 1,
      'tags' => '',
      'tags_from' => 'current',
      'output_type' => 'array',
      'output_params' => 1,
      'attachment_ids' => '',
      'mimetype' => '',
      'limit' => -1
    );
    $images = file_gallery_shortcode( $images_args );
    foreach($images as $image) {
      <my-html-code-per-each-image>
    }

    P.S. would be great to have a more detailed description for file_gallery_shortcode function (what can be used in ‘orderby’, what do ‘columns’ mean) for beginner programmers 🙂

Viewing 1 replies (of 1 total)
  • Plugin Author Aesqe

    @aesqe

    Hi dashaluna 🙂

    The easiest way would be to move the featured image to the first position in the thumbnails list on your post editing screen. You can drag and drop thumbnails to rearrange them and then click the “save attachment order” button to, well, save their order 🙂

    That way, the featured image will be the first one in your array.

    The other way is a bit more complicated and requires you to fetch the featured image id, check if the current attachment’s id is that same id in that foreach loop, remove it from array when found, and then push it back in at the beginning.

    Let me know if you need more help 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] [Plugin: File Gallery] featured images’ is closed to new replies.