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.

This tutorial is a bit more technical than our other docs, but we’ll walk you through the process step by step. In order to make your gallery titles links, we’ll need to create and upload a basic WordPress plugin.
  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');

If you’re unsure how to create a plugin file, follow these steps below:

  1. Open a text file and make sure that it is a plain text document. You can use a plain text editor like Notepad or a code editor of your choice.
  2. Next, copy and paste the code shown below into the file and save the file as envira-enable-features-images.php
  3. Once you’ve saved the file you can easily upload this directly to your /plugins directory on your server using FTP or you can right-click on the text document and zip (or compress).
  4. Finally, log in to your WordPress dashboard and go to Plugins » Add New » Upload Plugin and upload the .zip file you just created in the previous step.

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.