I don’t think I understand what you’re trying to do… So, essentially, you want to use WordPress’ regular featured image (which has to be manually set) if no external featured image is set, right?
That’s exactly what’ll happen if you specify a regular featured image and don’t set any external featured image with our plugin. Why do you want our plugin to use a WordPress URL to display the featured image?
Anyway, the function you need to look at is nelioefi_save_url. Just check that the $_POST['nelioefi_url'] is not set or empty and, if that’s the case, then recover the featured image URL just as you’re doing in your function.
Sorry, I have hard time explaining what I’m trying to do in english language. Please ignore my original post and let me try one more time.
When publishing a post, if external thumbnail URL is left empty I want it to be set automatically to my placeholder image URL. So when a post is published it has an external placeholder image.
I know only HTML and CSS, so I’m having trouble modifying this plugin.
Hi! Now I understand what you’re trying to do. If that’s the case, I’d recommend you change the function nelioefi_get_thumbnail_src in includes/nelio-efi-main.php, line 26, and use the following code (where we’ve added a couple of lines):
function nelioefi_get_thumbnail_src( $id ) {
$image_url = get_post_meta( $id, '_nelioefi_url', true );
if ( !$image_url || strlen( $image_url ) == 0 ) {
if ( !has_post_thumbnail( $id ) )
return 'http://example.com/link/to/external-placeholder.jpg';
return false;
}
return $image_url;
}
In the previous code, the first two lines check if the post $id has a external featured image. If it doesn’t, then we check if a regular featured image is set. If it isn’t, then the post defines no featured image, which means we can return the placeholder.
I tested it with default WordPress theme and it works, so thank you!
But for some reason my theme only displays thumbnail when I enter URL manually in post edit.
Now just have to figure out a way for it to work with my theme.
Can’t believe I figured this out… I just had to delete if and else parts of this code and it’s working with my theme!
<?php
if(has_post_thumbnail($post->post_id)){
the_post_thumbnail( array(520,293) );
}else{
$thumbnail[0]=function_exists('tm_get_default_image')?tm_get_default_image():'';
?><img src="<?php echo $thumbnail[0] ?>" alt="<?php the_title_attribute(); ?>" title="<?php the_title_attribute(); ?>"><?php
}
?>
I’m glad to know you figured it out! It’s time you enjoy WordPress! And don’t forget to rate and comment on the plugin!