• Resolved TLegenden

    (@tlegenden)


    Hi, i would like if the plugin took the first image in the post and sat it as featured image automatically ??

    I saw this thread but it was closed without answer from the one who suggested it, so i thought i could answer those questions because i want that too ??
    https://www.ads-software.com/support/topic/automation-and-various-sizes

    “should it be dynamic or could it be static? That is, imagine the first time you save the post, the first image is foo.jpg. We set that image as the featured image. Then, you go edit the post and change the first image of the post from foo.jpg to bar.jpg; what featured image should we use, now?”

    I would prefer if the image did not change when the first in the post is changed, but maybe someone else wants it to change, so why not make settings for it so people can choose?

    https://www.ads-software.com/plugins/external-featured-image/

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author David Aguilera

    (@davilera)

    Hi! Thanks for the answer, TLegenden. I’ll work on it as soon as I have some spare time (right now we’re pretty busy with our A/B Testing service for WordPress…)

    Hi.. I’m looking for this feature also.
    This would be great and save our time rather than set external featured images manually.

    I think static image link would be enough.
    But will be great if we update the post.. it’s recheck the first image in post then set the first image again.

    I’m try by put these code in my function.php child theme but doesn’t work:

    function auto_featured_image() {
        global $post, $posts;
    
        if (!has_post_thumbnail($post->ID)) {
            global $post, $posts;
              $first_img = '';
              ob_start();
              ob_end_clean();
              $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
              $first_img = $matches [1] [0];
    
              if(empty($first_img)){ //Defines a default image
                $first_img = "/images/default.jpg";
              $attached_image = $first_img;
    
          if ($attached_image) {
                  foreach ($attached_image as $attachment_id => $attachment) {
                       set_post_thumbnail($post->ID, $attachment_id);
                  }
             }
        }
    }
    // Use it temporary to generate all featured images
    add_action('nelioefi_post_meta_key', 'auto_featured_image');

    I only get “Array” text in admin post external featured image.

    If this will be a pro feature.. Yes.. of course I will buy for it ??
    Please make this plugin more powerfull very soon.

    Thank you for this great plugin.

    Plugin Author David Aguilera

    (@davilera)

    Hi MonkimoE,

    I haven’t started working on it yet (the amount of work we have right now is crazy! I hope I’ll have some spare time soon, during this summer :-D).

    Anyway, your code looks quite good, but the thing is we’re not using attachments for inserting the external featured images. Once we’ve officially implemented the function, I’ll let you know, guys!

    I too would like to cosign on this. This would be the last piece of the puzzle that I need. I have multiple editors and don’t want to have to train them (to remember) to set the image each time.

    I know you’re busy; I just want to show that I would be another person to use this great feature!

    Thanks for your time!

    Hi if found an easy workaround by chaining this plugin to the existing “WP Autoset Featured Image Plus” plugin.

    You have to manually change the Autoset plugin code to set the Meta information required by Nelio external image:

    Original relevant code block in wp-autoset-featured-image-plus/wpautosetfeaturedimageplus.php:

    if ($extImgUrl!="") {
        $thumbId = wpasfiCreateThumb($extImgUrl, $post_id);
        if ($thumbId) {
              update_post_meta( $post_id, '_thumbnail_id', $thumbId );
         }
    }

    New code block:

    if ($extImgUrl!="") {
        update_post_meta( $post_id, _nelioefi_url(), $extImgUrl);
    }

    thats it

    Thread Starter TLegenden

    (@tlegenden)

    Thanks, it works ??
    I’ll use this method until there is a real auto set for this plugin ??

    hi samy234 and TLegenden,

    Would it be possible to provide the plugin that you have put it together?
    I still can’t figure out and not working.

    Thanks,
    Lin

    Hi Samy234,

    Could you help me trouble shoot why my setup isn’t working?

    Hi thistlebean and tunlin007. I will check if i can use the code of the two plugins to build a new one that does this. What version of nelio and autoset are you using where it doesn’t work? I didn’t update the plugins since i changed them.

    Hello samy234,

    Thank you for the comment!

    Versions:

    Nelio : Version 1.2.0
    WP Autoset : Version 3.0

    This is a great workaround, thanks for sharing this!

    I have edited the code as above and finding that the image is being set in the backend of WP but not showing on the front end…not sure why.

    Will update if I figure it out.

    @pinkishhue,

    Same issue for me.

    Apparently what we desire is actually quite a complex problem to solve…

    Plugin Author David Aguilera

    (@davilera)

    Hey guys!

    I just uploaded a new version of the plugin that implements the “auto set image”. From now one, if a post doesn’t have a regular or external featured image set, it’ll use the first image in the content as such. And the best part is: there’s no need to use a second plugin along with Nelio External Featured Image for doing this!

    If you don’t want this behavior, you simply need to add the following line in your theme’s functions.php file:

    add_filter( 'nelioefi_use_first_image', '__return_false' );

    David,

    Thank you. This is awesome!

    Plugin Author David Aguilera

    (@davilera)

    Glad to help, @thislebean!

    And, please, don’t forget to rate the plugin!

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Auto set image’ is closed to new replies.