Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

Featured Image for Albums and Galleries

This guide will show you how to set a featured image for standalone galleries and albums.

  1. Create the Plugin
  2. Activate the Plugin
  3. FAQs

Create the Plugin

To allow the featured image to be set at the top of a standalone link for a gallery or album just add the following code to a new file at wp-content/plugins/envira-enable-features-images.php.

<?php
/**
* Plugin Name: Envira Gallery - Enable Featured Images
* Plugin URI: https://enviragallery.com
* Version: 1.0.0
* Author: Envira Gallery Team
* Author URI: https://enviragallery.com
* Description: Enables Featured Images for Envira CPT
*/
/**
* Enable comments on Envira Galleries
*
* @since 1.0.0
*
* @param    array   $post_args  Post Type Arguments
* @return   array               Post Type Arguments
*/
function envira_standalone_enable_thumbnails( $post_args ) {
     
    $post_args['supports'][] = 'thumbnail';
    return $post_args;
    
}
add_filter( 'envira_gallery_post_type_args', 'envira_standalone_enable_thumbnails' );
add_filter( 'envira_albums_post_type_args', 'envira_standalone_enable_thumbnails' );
/**
 * Adds the metabox for featured images.
 * 
 * @access public
 * @param mixed $pass_over
 * @return void
 */
function envira_standalone_thumbnail_metabox( $pass_over ){
	$pass_over[] = 'postimagediv';
	return $pass_over;
}
add_filter( 'envira_gallery_metabox_ids', 'envira_standalone_thumbnail_metabox');
add_filter( 'envira_albums_metabox_ids', 'envira_standalone_thumbnail_metabox');

Activate the Plugin

Navigate to the WordPress admin > Plugins and activate the Envira Gallery – Enable Featured Images plugin.

Now you can see that on the album and gallery screens you now have a place to set a featured image.

That’s it, you’ve successfully set a featured image for your gallery or album.


FAQs

Q: Where does the featured image display when viewing my standalone gallery or album?

A: This location and appearance of the featured image will depend on your site’s active theme. Some themes may not support the display of a featured image at all.
If you are not seeing the featured image you set for your gallery or album when viewing the standalone link be sure to check the functionality of your theme to ensure it supports the display of featured images.