• Resolved alejodec

    (@alejodec)


    Hi! Very good and very useful plugin.
    Sorry for my English, I use the Google translator. I also use a custom theme.

    I have the following problem: Use “Dave’s WordPress Live Search” and this plugin finds no thumbnail. I am novice in php and more I review the code I achievement Nelio not operate.

    Also I ask a question: Can I scale a thumbnail with Php with Width and Height? What would be the syntax?.

    From already thank you very much for the plugin and support.
    Best regards.

    https://wordpress.org/plugins/external-featured-image/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Nelio Software

    (@nelio)

    Hi Alejo! First of all, thanks for trying our plugin. WordPress offers different mechanisms to print a featured image. The two most important ones are [get_]the_post_thumbnail() and wp_get_attachment_image_src(). However, only the first one (which returns HTML code) offers a filter in which we can hook and, thus, change the featured image “on the fly”.

    I took a look at the plugin you mention and its source code. The plugin uses the second function I mentioned (wp_get_attachment_image_src()). However, if you take a look at file class-daves-wordpress-live-search-results.php line 91, you’ll see the plugin defines a filter called dwls_attachment_thumbnail. I think that you can hook there and change the featured image it shows.

    In order to do so, simply go to your theme’s functions.php file and define the following hook:

    add_filter( "dwls_attachment_thumbnail", "use_nelio_ext_fi", 10, 1 );
    function use_nelio_ext_fi( $old_featured_image ) {
       global $post;
       $image_url = get_post_meta( $post->ID, '_nelioefi_url', true );
       if ( $image_url && strlen( $image_url ) > 0 )
          return $image_url;
       else
          return $old_featured_image;
    }

    The previous function looks whether the current post has an external featured image. If it does, it is returned. Otherwise, the featured image the plugin would have set up is returned.

    Regarding width and height scaling: yes, there are some functions in PHP. Nonetheless, I recommend you stick to CSS scaling.

    Thread Starter alejodec

    (@alejodec)

    Ohhh ….. Thank you, IT WORKS!!

    Thank you very much not only for the solution, but for your time and dedication to provide the solution, for teaching and for this great plugin.

    Regards from Argentina.

    Plugin Author Nelio Software

    (@nelio)

    I am glad to hear, Alejo. Enjoy the plugin and don’t forget to 5-star the plugin!

    ¡Saludos desde Barcelona!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Real-time search does not find thumbnail.’ is closed to new replies.