Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #276415

    Hi,

    1. Is it possible to have a lightbox for the feature image in a blog post with image format selected (without using a plugin)?

    Using other formats like link or gallery, the feature image gets cropped – though the lightbox works.
    Maybe I should use one of those formats but change the featured images to display in their original size?

    2. Also the feature “Don’t display feature image on single post” doesn’t seem to be working, image is still shown

    thx

    #276424

    Hi Adenadoume!

    Yes, open up wp-content/themes/enfold/includes/helper-post-format.php and replace:

    
    	function avia_image_slideshow_filter($current_post)
    	{
    
    		$prepend_image = get_the_post_thumbnail(get_the_ID(), 'large');
    		$image = "";
    
    		if(!$prepend_image)
    		{
    			$image		= avia_regex($current_post['content'],'image');
    			if(is_array($image))
    			{
    				$image = $image[0];
    				$prepend_image = '<div class="avia-post-format-image"><img src="'.$image.'" alt="" title ="" /></div>';
    			}
    			else
    			{
    				$image		= avia_regex($current_post['content'],'<img />',"");
    				if(is_array($image))
    				{
    					$prepend_image = '<div class="avia-post-format-image">'.$image[0]."</div>";
    				}
    			}
    		}
    		else
    		{
    			$prepend_image = '<div class="avia-post-format-image">'.$prepend_image."</div>";
    		}
    
    			if(!empty($prepend_image) && is_string($prepend_image))
    			{
    				if($image) $current_post['content'] = str_replace($image, "", $current_post['content']);
    				$current_post['before_content'] = $prepend_image;
    				$current_post['slider']  = "";
    			}
    
    		return avia_default_title_filter($current_post);
    	}
    

    with

    
    	function avia_image_slideshow_filter($current_post)
    	{
    
    		$prepend_image = get_the_post_thumbnail(get_the_ID(), 'large');
            if($prepend_image)
            {
                $thumb_id = get_post_thumbnail_id();
                $thumb_url = wp_get_attachment_image_src($thumb_id,'full', false);
            }
    
    		$image = "";
    
    		if(!$prepend_image)
    		{
    			$image		= avia_regex($current_post['content'],'image');
    			if(is_array($image))
    			{
    				$image = $image[0];
    				$prepend_image = '<div class="avia-post-format-image"><a href="'.$image.'" class="lightbox"><img src="'.$image.'" alt="" title ="" /></a></div>';
    			}
    			else
    			{
    				$image		= avia_regex($current_post['content'],'<img />',"");
    				if(is_array($image))
    				{
    					$prepend_image = '<div class="avia-post-format-image"><a href="'.$image[0].'" class="lightbox">'.$image[0]."</a></div>";
    				}
    			}
    		}
    		else
    		{
    			$prepend_image = '<div class="avia-post-format-image"><a href="'.$thumb_url[0].'" class="lightbox">'.$prepend_image."</a></div>";
    		}
    
    			if(!empty($prepend_image) && is_string($prepend_image))
    			{
    				if($image) $current_post['content'] = str_replace($image, "", $current_post['content']);
    				$current_post['before_content'] = $prepend_image;
    				$current_post['slider']  = "";
    			}
    
    		return avia_default_title_filter($current_post);
    	}
    

    You can also insert the modified function into your child theme functions.php file.

    2) I tested the option on my test server and it works just fine. Make sure that wp-content/themes/enfold/includes/loop-index.php is up to date and contains this code:

    
    if(is_single($initial_id) && get_post_meta( $current_post['the_id'], '_avia_hide_featured_image', true ) ) $current_post['slider'] = "";
    

    If not replace:

    
    $current_post['slider']  	= get_the_post_thumbnail($current_post['the_id'], $size);
    

    with

    
    $current_post['slider']  	= get_the_post_thumbnail($current_post['the_id'], $size);
    if(is_single($initial_id) && get_post_meta( $current_post['the_id'], '_avia_hide_featured_image', true ) ) $current_post['slider'] = "";
    

    Cheers!
    Peter

    #276429

    1) Lightbox works in image post, cheers!

    2) Code is updated and works in hiding featured image in all formats except for image posts (which makes sense actually)

    Since the lightbox works I have no need to hide feature image, so all is good!

    Thanks.

    • This reply was modified 1 month, 3 weeks ago by  Adenadoume.
    #276468

    Hi!

    Yes, the image post format doesn’t make sense without an image ;)

    Cheers!
    Peter

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

You must be logged in to reply to this topic.