Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeremy Felt

    (@jeremyfelt)

    Hi Jen,

    I explored a couple different ways of doing this today, but wasn’t able to get to anything solid.

    To make the plugin fill the post content in a useful way, I need to determine the best way to present and handle options for what size the image should be by default and how it should be aligned. When a theme has featured image support, these decisions are already taken care of by displaying the image separately from the post content.

    I’ll keep rolling some ideas around in my head to see if I can figure out a good solution.

    Any word on this? I really want this feature. Would mean awesome things for my stock photo site as well as a donation to you for a plugin that would actually be useful.

    Plugin Author Jeremy Felt

    (@jeremyfelt)

    Version 0.6 has just been posted and adds filters that allow you to change the new post’s title, content, and categories as files are uploaded.

    A full write up with examples is here:

    https://www.jeremyfelt.com/wordpress/2012/04/14/filters-in-automatic-featured-image-posts/

    @nuessly – check out https://codex.www.ads-software.com/Post_Thumbnails as an option for the theme you are using. You really do have more flexibility when using featured images rather than relying on the post content. A different size can be pulled and displayed whenever and on whichever template you need it.

    Thread Starter JenRed

    (@jenred)

    Jeremy – thank you SO much. This is awesome! ??

    Jen

    Thread Starter JenRed

    (@jenred)

    Also am I right in thinking that this inserts the photo into the post at whatever the size was when you uploaded it?

    Is there another filter I can use to tell it to resize to width of 640px for instance? or tell it to use one of the custom photo sizes?

    Thanks again

    Jen

    Plugin Author Jeremy Felt

    (@jeremyfelt)

    @jen – You are correct. Because all of the image crunching is done by WordPress via AJAX after the upload is complete, there is only one image size available. Even if I request the source for a different image size, it returns the only one it has.

    Two (maybe more) ways to handle this on your end.

    First:

    $my_uploaded_image = wp_get_attachment_image_src( $attachment_id );
    $post_content = '<img src="' . $my_uploaded_image[0] . '">';
    return $post_content;

    In this example (pulled partly from the gist I have in this writeup), the array $my_uploaded_image also has keys [1] and [2] that give you the image size. (See codex docs for wp_get_attachment_image_src()). You could then perform some math to resize those values before using them in the IMG element like so:

    <img src="$my_uploaded_image[0]" width="$my_image_width" height="$my_image_height">

    That at least sizes the IMG element correctly, though it will still have the browser load the full size image in the background, which could be less than ideal.

    OR

    If you can modify the theme you are using to use featured images (See codex docs for Post Thumbnails), you can add code to template files to display whichever size you want in any given area.

    As a way too brief example, something like this in your single.php template:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <h1>Post Title: <?php the_title() ?></h1>
    <div class="my-post-featured-image">
        <?php the_post_thumbnail( 'my-custom-size' ); ?>
    </div>
    <?php endif; endwhile; ?>

    This would give you a display of the post title and the my-custom-size version of your featured image, which, for the sake of being detailed enough, is defined in functions.php like so:

    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 'my-custom-size', 640, 9999 );

    This adds support for a custom size thumbnail that will resize the image to 640 and keep the height automatic.

    The second option is my favorite, as this is what the plugin is really intended to help with.

    It also allows you to change your mind over time with your photo posts. If you decide next week that you’d rather have images with an 800px width in your layout, it would be a matter of using a different post thumbnail size in your template rather than having to go back and manually change things.

    Also (you can tell I like this option), it becomes easier to display different size images depending on the template – archive, search, home, author, etc…

    Hope that helps!

    even if it were an additional plugin to take the featured image and include it in the post, that would be awesome ?? i use an image resizer to resize the images to the size i want and THEN upload. your original plugin saves alot of time but i wanted to forward the posts to my TUMBLR account but unfortunately, the featured images arent sent in that case, only what is in the post, so the TUMBLR posts end up being empty ??

    would it be possible to include the images in the post itself? i read through this post by JenRed but couldnt tell if/how to do it from your description.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Automatic Featured Image Posts] Add Image to body of Post as well as adding Featured Image’ is closed to new replies.