This topic has 5 replies, 2 voices, and was last updated 10 years by rikbutterflyskull.
-
Author
-
February 11, 2016 at 17:29 #103363
rikbutterflyskull
ParticipantHi, when we use that function in Theme Option, the ajax search put the default featured image also for pages and custom post types (cpt) as gd_place, if pages and cpt does not have a featured image set.
See the screenshot.
February 11, 2016 at 17:40 #103372sharmstr
ModeratorThat’s not a bug. That’s how it was coded. I’ll move this to the feature request section to see about changing that in a future release.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionFebruary 11, 2016 at 20:14 #103415rikbutterflyskull
ParticipantNo it’s not a bug, but is nosense because i set a featured image in Blog Option for Blog Post.
Thanks for your reply, i’ll check this code lines by myself for a solution.
February 11, 2016 at 20:46 #103418sharmstr
ModeratorThat option is really old it was never coded to work only on wp posts. In that respect, its not a bug.
If you want to fiddle with it yourself, check out the kleo_get_post_thumbnail function in /kleo-framework/lib/function-core.php
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionFebruary 16, 2016 at 14:58 #104115rikbutterflyskull
ParticipantHi, in function-core.php i replace in ‘function kleo_get_post_thumbnail_url( $post_id = null )’
COPY CODE//Defines a default image if ( empty( $image_url ) ) { $image_url = sq_option_url('blog_default_image', ''); } return $image_url;with
COPY CODE//Defines a default image if ( empty( $image_url ) && get_post_type() == 'post' ) { $image_url = sq_option_url('blog_default_image', ''); } elseif ( empty( $image_url ) and get_post_type() == 'any' ) { $image_url = ''; } return $image_url;I don’t know if it’s the best solution, but is fully works only in Search Result page. In Search dropdown results the ‘sq_option_url(‘blog_default_image’, ”)’ isn’t showed (both posts and pages), but the Featured image in Post Setup is working, better than before. Now i have to test the Page Featured Image.
I’ll check the Search Ajax Dropdown results later (theme-option.php). If needed, can i ask you some techical info though is not covered by Support Service?
February 18, 2016 at 02:54 #104505rikbutterflyskull
ParticipantI fix that.
kleo-framework/lib/function-core.php
COPY CODEfunction kleo_get_post_thumbnail_url( $post_id = null ) { $image_url = ''; $thumb = get_post_thumbnail_id( $post_id ); //all good. we have a featured image $featured_image_url = wp_get_attachment_url( $thumb ); if ( $featured_image_url ) { $image_url = $featured_image_url; } elseif ( sq_option( 'blog_get_image', 1 ) == 1 ) { global $post; if (! is_object($post) && $post_id != NULL ) { $post = setup_postdata( get_post($post_id) ); } ob_start(); ob_end_clean(); if (isset($post->post_content)) { $output = preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $post->post_content, $matches); $image_url = isset($matches[1][0]) ? $matches[1][0] : null; } } //Defines a default image if ( empty( $image_url ) && get_post_type() == 'post' ) { //** NEW Filter the post_type to 'post' $image_url = sq_option_url('blog_default_image', ''); } return $image_url; }lib/theme-functions.php // function kleo_ajax_search() – Line 647
Line 770-785
COPY CODE$format = get_post_format( $post->ID ); if ( $img_url = kleo_get_post_thumbnail_url( $post->ID ) ) { $image = aq_resize( $img_url, 44, 44, true, true, true ); if( ! $image ) { $image = $img_url; } $image = '<img src="'. $image .'" class="kleo-rounded">'; } else { if ($format == 'video') { $image = "<i class='icon icon-video'></i>"; } elseif ($format == 'image' || $format == 'gallery') { $image = "<i class='icon icon-picture'></i>"; } else { $image = "<i class='icon icon-link'></i>"; } }becomes
COPY CODE$format = get_post_format( $post->ID ); if ( $img_url = kleo_get_post_thumbnail_url( $post->ID ) ) { $image = aq_resize( $img_url, 44, 44, true, true, true ); // if( ! $image ) { // $image = $img_url; // } $image = '<img src="'. $image .'" class="kleo-rounded">'; } else { if ($format == 'video') { $image = "<i class='icon icon-video'></i>"; } elseif ($format == 'image' || $format == 'gallery') { $image = "<i class='icon icon-picture'></i>"; } else { if (get_post_type( $post->ID ) == 'post') { //** NEW - Post_type filter $image = '<img src="'. sq_option_url('blog_default_image', '') .'" class="kleo-rounded ajax_search_image">'; //** NEW - Providing default image url + .ajax_search_image css class } else { $image = "<i class='icon icon-link'></i>"; } } }Results on screenshots
-
AuthorPosts
The topic ‘Default Featured Image Placeholder Issue’ is closed to new replies.