WordPress.org

Ready to get started?Download WordPress

Forums

Eazyest Gallery
Featured image (2 posts)

  1. tompasworld
    Member
    Posted 6 months ago #

    Hi,

    First of all, nice plugin.

    Now, how do I set "Featured image" in folder icons?

    If I go to settings > eazyest gallery, I see a setting "Folder icons" which I can set to "Featured image".

    How do I tell this setting which photo I want to be featured?

    Regards,
    Thomas

    http://wordpress.org/plugins/eazyest-gallery/

  2. klihelp
    Member
    Plugin Author

    Posted 5 months ago #

    This one is not easy to get it, because the folder icons options exclude the featured image checks, in ezg_folder_thumbnail() function.

    ----

    To display the featured image as folder icon, I had to customize the whole gallery output,

    - add custom gallery_filter

    add_filter("post_gallery", "klizg_gallery_filter",10,2);

    - add custom ezg_subfolders() action

    remove_action('eazyest_gallery_after_folder_content','ezg_subfolders', 5);
    add_action('eazyest_gallery_before_folder_content','klizg_subfolders', 6);

    - add/replace ezg_folder_thumbnail() with custom code inside custom ezg_subfolders();
    and add your custom post_thumbnail_attr() function to check for the icon attributes.

    // $attr = $this->post_thumbnail_attr( $post_id );
    //
    $attr = klizg_post_thumbnail_attr( $query->ID, 'medium' );
    $image_html = empty( $attr['src'] ) ? '' : sprintf( '<img width="%d" height="%d" src="%s" class="attachment-thumbnail wp-post-image folder-icon" alt="%s" />',
        $attr['width'],
        $attr['height'],
        $attr['src'],
        $attr['alt']
    );
    echo $image_html;
    // the custom post_thumbnail_attr()
    function klizg_post_thumbnail_attr( $post_id = 0, $kli_size = 'thumbnail' ) {
        global $post;
        $post_id = 0 != $post_id ? $post_id : $post->ID;
    
        $thumbnail_id = eazyest_frontend()->post_thumbnail_id( null, $post_id, '_thumbnail_id' );
    
        $option = eazyest_gallery()->folder_image;
        $src = '';
        $icon = apply_filters( 'eazyest_gallery_folder_icon', eazyest_gallery()->plugin_url . 'frontend/images/folder-icon.png' );
        if ( 'none' != $option ) {
            if ( 'icon' == $option )
                $src = $icon;
            else {
                if ( ! empty( $thumbnail_id ) ) {
                    // $wp_src = eazyest_folderbase()->get_attachment_image_src( $thumbnail_id, 'thumbnail' );
                    $wp_src = eazyest_folderbase()->get_attachment_image_src( $thumbnail_id, $kli_size );
                    $src = $wp_src[0];
                } else {
                    $src = $icon;
                }
            }
        }
        $attr = array(
            'width'  => $wp_src && $wp_src[1] ? $wp_src[1] : intval( get_option( "thumbnail_size_w" ) ),
            'height'  => $wp_src && $wp_src[1] ? $wp_src[2] : intval( get_option( "thumbnail_size_h" ) ),
            // 'width'  => intval( get_option( "thumbnail_size_w" ) ),
            // 'height' => intval( get_option( "thumbnail_size_h" ) ),
            'src'    => $src,
            'alt'    => __( 'Folder Icon', 'eazyest-gallery' )
        );
    
        return apply_filters( 'eazyest_gallery_folder_thumbnail_attr', $attr, $post_id );
    }

    --

    `

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.