A switch to turn the post's featured image off and on.

  • Idea
  • Updated 2 years ago
I would find it very useful to have a check box in the post editing interface that would shut off the big image above the title.

Then the post could still have a featured image selected to use on the home and search pages but the individual post page format would become more flexible.
Photo of Steve Hunter

Steve Hunter

  • 5 Posts
  • 0 Reply Likes
  • excited

Posted 4 years ago

  • 6
Photo of lesley

lesley

  • 29 Posts
  • 0 Reply Likes
Oh yes, please.....this would be very helpful. I have spent a few hours today searching the web for advice on how to either remove the large featured image from the top of blog posts or make it small enough to fit below the post title.

There seems to be several old ways to do it with code that don't work with AF 2.0.
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
Open Single.php find // Grab The Blog Category
below it modify part of code this way
// Grab The Blog Category
$af_blog_catid = of_get_option( $shortname . '_blog_cat');
$af_img_display = of_get_option($shortname . '_image_display');
$af_img_slider_count = get_post_meta($post->ID, 'slider_count_value', true);
$show_it = get_post_meta($post->ID, 'show_image', true);
// If this isn’t a blog post, show the AutoFocus Entry Image (See: functions.php)
if ( !in_category($af_blog_catid) && $show_it == true)
af_single_entry_image($af_img_display, $af_img_slider_count);


Then in autofocus-post-meta

add
'showimage' => array(
'name' => 'show_image',
'title' => __('Show Huge Image?','autofocus'),
'type' => 'checkbox',
'std' => '',
'description' => __('Show a large image 800px wide or 600px tall.)','autofocus')),


after copyright_value

Save and Test

I did this with very brief test. So you need to test it extensively.
Photo of Adam Fratino

Adam Fratino

  • 6 Posts
  • 0 Reply Likes
Thanks for the solution. It works great for me. Dumb question: does this give me the option to turn it on and off, or is this just a solution to remove it? I can't find the checkbox you created.
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
On the post editing page ( admin ) you have a checkbox , unchecked by default.
Next to "Show Gallery".
Photo of Alexander 'Måge' Christiansen

Alexander 'Måge' Christiansen

  • 6 Posts
  • 0 Reply Likes
Hey AxelYa

I've been searching for exact the same solution.
However yours do have the consequences of removing every written material as well as other added photos on the posts.

Really need to get this working - do you have any other good ideas?

Thanks in advance!
Alex, Denmark.
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
You are welcome to experiment .

Update : I can't replicate the problem on my test site. The switch turns off the large image above the post title.
Below the title everything normal. Text and inpost images are there.

"removing every written material as well as other added photos on the posts"

Can you elaborate on that.
Photo of Alexander 'Måge' Christiansen

Alexander 'Måge' Christiansen

  • 6 Posts
  • 0 Reply Likes
Hey again AxelYa.
First thanks for your help.

qoute:
"removing every written material as well as other added photos on the posts"
Can you elaborate on that.

The thing is, that the code actually works in some way. The chosen featured image on my homepage are removed from my chosen page when i load it. However, the entire writen material in that specific post are in some ways gone from the page.

Example:
I have 4 pages, which are shown by a featured image in my grid on my homepage. When i do click on one of these photos and acces the page, the featured image IS removed from the page (which is what i do want to happen!) - however, my written material and my gallery is gone as well.

Hope this explains the problem better.

Thanks in advance,
Alex
Denmark
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
Can you post code from single.php. Just the part between autofocus_nav_above(); and autofocus_nav_below();

also can you give a link to the specific post.
Photo of Alexander 'Måge' Christiansen

Alexander 'Måge' Christiansen

  • 6 Posts
  • 0 Reply Likes
@AxelYa.

Thanks for your quit replies.

I tried it again - and it worked out great!

Thanks for your patience.
Photo of jonathan.c.murphyJ

jonathan.c.murphy

  • 3 Posts
  • 0 Reply Likes
I tried this too. The image now loads behind the text.

i can't give an example right now because I need the site to be up. I fixed it the dumb way by just declaring the height of the entry-gallery-container class.

when i get a chance i will put up another site with the issue.

It is odd to me such a small change to single.php would cause this to break. It is just checking to see if the "show_image" box is checked.
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
Can you post here the code from single.php. between autofocus_nav_above(); and autofocus_nav_below();

I want to try to replicate the issue.
Photo of jonathan.c.murphyJ

jonathan.c.murphy

  • 3 Posts
  • 0 Reply Likes
I stripped out a couple lines but the problem was occurring with the default fresh install of auto-focus (plus the above suggested changes). I basically just took out the date function in the header, and the af_meta utility (which lists category, comments, etc..).

 	<?php 

// AutoFocus Nav Above (See: functions.php)
autofocus_nav_above();
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php
global $posts, $shortname;
// Grab The Blog Category
$af_blog_catid = of_get_option( $shortname . '_blog_cat');
$af_img_display = of_get_option($shortname . '_image_display');
$af_img_slider_count = get_post_meta($post->ID, 'slider_count_value', true);
$show_it = get_post_meta($post->ID, 'show_image', true);
// If this isn�t a blog post, show the AutoFocus Entry Image (See: functions.php)
if ( !in_category($af_blog_catid) && $show_it == true)
af_single_entry_image($af_img_display, $af_img_slider_count);

?>

<header>
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>

<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'autofocus' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->

<footer class="entry-utility">
<p class="entry-meta">

<?php if ( get_post_meta($post->ID, 'enable_flickr', true) == FALSE && of_get_option($shortname . '_show_exif_data') == TRUE && has_post_thumbnail() && ( get_post_meta($post->ID, 'videoembed_value', true) == '' && get_post_meta($post->ID, 'show_gallery', true) == FALSE )) { ?>
<span class="exif-data"><a href="<?php echo af_exif_link(); ?>#exif-data" title="<?php echo esc_attr__( 'View EXIF data', 'autofocus' ) ?>"><?php _e('View EXIF Data', 'autofocus') ?></a>.</span>
<?php } ?>

<?php if ( get_post_meta($post->ID, 'enable_flickr', true) && get_post_meta($post->ID, 'flickr_link', true) ) { ?>
<span class="flickr-link"><?php _e('View ', 'autofocus'); ?><a href="<?php echo get_flickr_photo_set_link($post->ID); ?>" target="_blank" title="<?php echo esc_attr__( 'View Flickr set', 'autofocus' ) ?>"><?php _e('Flickr set', 'autofocus') ?></a>.</span>
<?php } ?>

<?php edit_post_link( __( 'Edit', 'autofocus' ), '<span class="edit-link">', '</span>' ); ?>
</p><!-- .entry-meta -->
<?php get_sidebar(); ?>
</footer><!-- .entry-utility -->

</article><!-- #post-## -->

<?php
// AutoFocus Nav Below (See: functions.php)
autofocus_nav_below(); ?>
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
I placed the code in my single.php - no problem at all. I can't replicate what you describing.

May be a screenshot will help.
Photo of KlausWK

KlausW

  • 1 Post
  • 0 Reply Likes
First of all thanks for this piece of code - it worked perfectly fine at the beginning, but now I had to realize that as soon as I make any change to one post, the big image above the title is shown again, although the checkbox is not set... and nothing that helps, cannot undo it anymore...

Will try to figure out something, but I am no php expert at all...
Photo of Allan Cole

Allan Cole, Owner

  • 2047 Posts
  • 112 Reply Likes
This is a pretty good idea. I may include it in a future update...
Photo of dannyD

danny

  • 7 Posts
  • 0 Reply Likes
Hi AxelYa, thanks for posting your tip. It works...for the most part, which is why I am writing.

Of course, now I have the ability to turn on or off the large image, which is great. However, when I do turn it on, the image shows up behind the post's text, title, etc. Here is a screenshot showing what I mean:



I'm not sure how to fix this, can you help?

Oh yes, here is the single.php portion between autofocus_nav_above(); and autofocus_nav_below();



// AutoFocus Nav Above (See: functions.php)
autofocus_nav_above();
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php
global $posts, $shortname;
// Grab The Blog Category
$af_blog_catid = of_get_option( $shortname . '_blog_cat');
$af_img_display = of_get_option($shortname . '_image_display');
$af_img_slider_count = get_post_meta($post->ID, 'slider_count_value', true);
$show_it = get_post_meta($post->ID, 'show_image', true);

// If this isn�t a blog post, show the AutoFocus Entry Image (See: functions.php)
if ( !in_category($af_blog_catid) && $show_it == true)
af_single_entry_image($af_img_display, $af_img_slider_count);

?>

<header>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php af_posted_on(); ?>
</header>

<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'autofocus' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->

<footer class="entry-utility">
<p class="entry-meta">
<?php af_post_meta(); ?>

<?php comments_popup_link( '<span class="comments-link">' . __( 'Leave a comment', 'autofocus' ) . '</span>', '<span class="comments-link">' . __( '1 Comment', 'autofocus' ) . '</span>', '<span class="comments-link">' . __( '% Comments', 'autofocus' ) . '</span>', '', '' ); ?>

<?php if ( get_post_meta($post->ID, 'enable_flickr', true) == FALSE && of_get_option($shortname . '_show_exif_data') == TRUE && has_post_thumbnail() && ( get_post_meta($post->ID, 'videoembed_value', true) == '' && get_post_meta($post->ID, 'show_gallery', true) == FALSE )) { ?>
<span class="exif-data"><a href="<?php echo af_exif_link(); ?>#exif-data" title="<?php echo esc_attr__( 'View EXIF data', 'autofocus' ) ?>"><?php _e('View EXIF Data', 'autofocus') ?></a>.</span>
<?php } ?>

<?php if ( get_post_meta($post->ID, 'enable_flickr', true) && get_post_meta($post->ID, 'flickr_link', true) ) { ?>
<span class="flickr-link"><?php _e('View ', 'autofocus'); ?><a href="<?php echo get_flickr_photo_set_link($post->ID); ?>" target="_blank" title="<?php echo esc_attr__( 'View Flickr set', 'autofocus' ) ?>"><?php _e('Flickr set', 'autofocus') ?></a>.</span>
<?php } ?>

<?php edit_post_link( __( 'Edit', 'autofocus' ), '<span class="edit-link">', '</span>' ); ?>
</p><!-- .entry-meta -->
<?php get_sidebar(); ?>
</footer><!-- .entry-utility -->

</article><!-- #post-## -->

<?php
// AutoFocus Nav Below (See: functions.php)
autofocus_nav_below(); ?>
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
Ok. I found when it happens. On the post editing page there are several options
below the text area : copyright value, videoembed, Show Sliding Image Gallery? ...

Show Sliding Image Gallery? is checked by default. If you don't have a gallery uncheck it.
Photo of dannyD

danny

  • 7 Posts
  • 0 Reply Likes
First of all, thanks so much for the quick response. You're awesome. However, it works in a weird way. Let me explain:

1. If I check the box "Show Huge Image", and click the Update button, the "Show Sliding Image Gallery" box automatically 'checks' itself.

2. But, if I UN-check the box "Show Huge Image", then the "Show Sliding Image Gallery" button stays unchecked.

In Scenario 2, the post looks fine, but the large image actually is displayed on the post, even though the "Show Huge Image" box is unchecked. So, its like its working in reverse.

Bottom line is, I can't have the 1st box checked and the other unchecked. Do you know why that is?
Photo of dannyD

danny

  • 7 Posts
  • 0 Reply Likes
ok, this is weird, on some other posts, its working correctly. but i think its because they haven't been updated since changing the php files. If I update them, then they also act weird.
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
Yes, it is a bug in the post-meta code. Some time ago I posted a solution. There are just a couple of lines need to change. You can search my threads for that code.
Photo of dannyD

danny

  • 7 Posts
  • 0 Reply Likes
got it. Thanks Axel.
Photo of DD

D

  • 5 Posts
  • 0 Reply Likes
Has anyone had any joy with this with Autofocus Pro Version 2.0.6?

(I don't see the 'huge image' option displayed when editing a post)

Cheers,
D.
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
it is not in the original theme, you are supposed to edit files to have this option
Photo of DD

D

  • 5 Posts
  • 0 Reply Likes
Yes, I understand that. I edited the theme files verbatim, following the instructions letter for letter (using a copy of Autofocus Pro v2.0.6, editing single.php and autofocus-post-meta, replacing the relevant section of text), but I do not see an option appearing with regards to 'huge image' or similar, when editing posts.

I can simply comment out the display of the images in the single.php, which achieves the goal. But having the option of turning this on and off, as per the OP / re your (AxelYa's) original post, would be optimal :-)
Photo of DD

D

  • 5 Posts
  • 0 Reply Likes
Forgot to mention: using Wordpress v3.4.1

Here is what the post options look like for any old post (screen shot):



Here is an excerpt from autofocus-post-meta.php:

-------------

* Post Meta Options
* New Array For Video Embed Codes, Copyright info, , and Image Position Gallery Display Option
*/
$af_option_meta_boxes = array(
"video" => array(
"name" => "videoembed_value",
"title" => __("Embed URL","autofocus"),
"type" => "text",
"std" => "",
"description" => __("Paste your oEmbed URL here. (Examples: https://vimeo.com/7757262 or https://www.youtube.com/watch?v=xwnJ5B...,

"copyright" => array(
"name" => "copyright_value",
'showimage' => array(
'name' => 'show_image',
'title' => __('Show Huge Image?','autofocus'),
'type' => 'checkbox',
'std' => '',
'description' => __('Show a large image 800px wide or 600px tall.)','autofocus')),
"type" => "text",
"std" => "",
"description" => __("Text entered here will replace the default Photo credit. (Example: © 2012 Photographer Name. All rights reserved.)","autofocus")),

"showgallery" => array(
"name" => "show_gallery",
"title" => __("Show Sliding Image Gallery?","autofocus"),
"type" => "checkbox",
"std" => "FALSE",
"description" => __("Show a sliding Gallery of attached images above the post title? (Limited to 10 images. IMPORTANT: All images must be at least 800px wide or 600px tall.)","autofocus")),

-----------

Here is an excerpt from single.php:

-----------

>

ID, 'slider_count_value', true);
$show_it = get_post_meta($post->ID, 'show_image', true);
// If this isn’t a blog post, show the AutoFocus Entry Image (See: functions.php)
if ( !in_category($af_blog_catid) && $show_it == true)
af_single_entry_image($af_img_display, $af_img_slider_count);

?>





'' ) ); ?>
<!-- .entry-content -->



ID, 'enable_flickr', true) == FALSE && of_get_option($shortname . '_show_exif_data') == TRUE && has_post_thumbnail() && ( get_post_meta($post->ID, 'videoembed_value', true) == '' && get_post_meta($post->ID, 'show_gallery', true) == FALSE )) { ?>
.

ID, 'enable_flickr', true) && get_post_meta($post->ID, 'flickr_link', true) ) { ?>
.



<!-- .entry-meta -->

<!-- .entry-utility -->

<!-- #post-## -->

// AutoFocus Nav Below (See: functions.php)
autofocus_nav_below(); ?>

-----------
Photo of DD

D

  • 5 Posts
  • 0 Reply Likes
OK, solved it. I was taking the instructions too literally, and was pasting the 'huge image' code into autofocus-post-meta.php too early (right after the copyright value)... Instead, I have now pasted it AFTER the copyright ARRAY finishes.

And that works.

So, the code block looks like this in autofocus-post-meta.php......

----

"copyright" => array(
"name" => "copyright_value",
"title" => __("Photo Credit","autofocus"),
"type" => "text",
"std" => "",
"description" => __("Text entered here will replace the default Photo credit. (Example: © 2011 Photographer Name. All rights reserved.)","autofocus")),

'showimage' => array(
'name' => 'show_image',
'title' => __('Show Huge Image?','autofocus'),
'type' => 'checkbox',
'std' => '',
'description' => __('Show a large image 800px wide or 600px tall.)','autofocus')),

"showgallery" => array(
"name" => "show_gallery",
"title" => __("Show Sliding Image Gallery?","autofocus"),
"type" => "checkbox",
"std" => "FALSE",
"description" => __("Show a sliding Gallery of attached images above the post title? (Limited to 10 images. IMPORTANT: All images must be at least 800px wide or 600px tall.)","autofocus")),
Photo of Thibaut Heeren

Thibaut Heeren

  • 4 Posts
  • 0 Reply Likes
Yesterday I bought the latest pro version. Is there already a user friendly way to disable the entry image or is editing the php file the only option.
Kr
Photo of Thibaut Heeren

Thibaut Heeren

  • 4 Posts
  • 0 Reply Likes
bump