• Resolved Film Complet En Francais

    (@film-complet-en-francais)


    I modified this function in edit-post.php line 26 so it sets my custom URL automatically if nelioefi_url is not provided.

    function nelioefi_url_metabox( $post ) {
    	$nelioefi_url = get_post_meta( $post->ID, '_nelioefi_url', true );
    	$imageid = get_post_meta(get_the_ID(),'id',true);
    	$custom_image_url = get_image_detail($imageid, "image");
        if ($nelioefi_url == ''){
    	$nelioefi_url = $custom_image_url;
    	}
    	$has_img = strlen( $nelioefi_url ) > 0;
            ...

    The problem is I have to save post twice for it to work. Is it possible to fix this?

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

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

    (@nelio)

    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.

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    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.

    Plugin Author Nelio Software

    (@nelio)

    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.

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    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.

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    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
    }
    ?>

    Plugin Author Nelio Software

    (@nelio)

    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!

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

The topic ‘Auto’ is closed to new replies.