Bug fix to show image in post
-
This is a small patch to properly show featured image in a post if the theme supports it
in
admin/class-cust-li-fi-admin.php
, replace the following functionfunction cust_li_fi_thumbnail_fallback( $html, $post_id, $post_thumbnail_id, $size, $attr ) { $clink = get_post_meta( get_the_ID(), '_custom_url_image', true ); if ( empty( $html ) || !empty ($clink) && is_singular()) { $width = $size == 'post-thumbnail' ? get_option( 'thumbnail_size_w' ) : NULL; $height = $size == 'post-thumbnail' ? get_option( 'thumbnail_size_h' ) : NULL; $html = sprintf( '<a href="%s" title="%s" target="_blank" class="ex-link">%s</a>', $clink, esc_attr( get_the_title( $post_id ) ), empty($html) ? sprintf( '<img src="%s" style="%s" />', $clink, empty($height) && empty($height) ? 'width: 100%; height: auto; max-width: 100vw' : sprintf( '%s%s', empty($width) ? '' : "width: ${width}px;", empty($height) ? '' : "height: ${height}px;") ) : $html); } return $html; }
also add another hook to the very end of the file
add_action('has_post_thumbnail', function($has_thumbnail = NULL, $post = NULL, $thumbnail_id = NULL) { $clink = get_post_meta( get_the_ID(), '_custom_url_image', true ); return !empty($clink); });
While this is not ideal, but it gets the job done. Also be careful when you are replacing the function code, as the code itself is rather badly formatted.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Bug fix to show image in post’ is closed to new replies.