WordPress.org

Ready to get started?Download WordPress

Forums

User Submitted Posts
[resolved] Images posted as Featured images? (15 posts)

  1. pallisvans
    Member
    Posted 1 year ago #

    Hi, is it possible to have an image posted as a featured image? How about user-submitted image text?

    http://wordpress.org/extend/plugins/user-submitted-posts/

  2. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

  3. pallisvans
    Member
    Posted 1 year ago #

    Wow, instant support :) Thanks a million Jeff and your plugin is the best I've run across for this kind of thing.

  4. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    Happy to help! Thanks for trying the plugin :)

  5. yoyos33
    Member
    Posted 1 year ago #

    Don't know if it's the right thing to do but I needed only one image to be sent and displayed directly as featured image. I edited the plugin like this:

    in user-submitted-posts.php

    I changed :

    add_post_meta($newPost, $usp_post_meta_Image,wp_get_attachment_url($attachmentId));

    by:

    if ($i > 0)
      add_post_meta($newPost, $usp_post_meta_Image,wp_get_attachment_url($attachmentId));
    else
      set_post_thumbnail($newPost,$attachmentId);
  6. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    Here is the recommended way of doing it:

    http://wp-mix.com/set-attachment-featured-image/

  7. danicasati
    Member
    Posted 1 year ago #

    yoyos33, I can't find your string in user-submitted-post.php.
    I'm using 20130104 version with WP 3.5.1.

  8. abouasy
    Member
    Posted 1 year ago #

    i used code from wp-mix .. i past below in function.php but it display now only one image in the post >>

    what if i would like visitor to upload 3 images

    // featured images
    add_theme_support('post-thumbnails');
    set_post_thumbnail_size(130, 100, true); // width, height, hard crop
    
    // @ http://wp-mix.com/set-attachment-featured-image/
    add_filter('the_content', 'set_featured_image_from_attachment');
    function set_featured_image_from_attachment($content) {
    	global $post;
    	if (has_post_thumbnail()) {
    		// display the featured image
    		$content = the_post_thumbnail() . $content;
    	} else {
    		// get & set the featured image
    		$attachments = get_children(array(
    			'post_parent' => $post->ID,
    			'post_status' => 'inherit',
    			'post_type' => 'attachment',
    			'post_mime_type' => 'image',
    			'order' => 'ASC',
    			'orderby' => 'menu_order'
    		));
    		if ($attachments) {
    			foreach ($attachments as $attachment) {
    				set_post_thumbnail($post->ID, $attachment->ID);
    				break;
    			}
    			// display the featured image
    			$content = the_post_thumbnail() . $content;
    		}
    	}
    	return $content;
    }
  9. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    To display images in posts, you'll need to use either WP's built-in template tags or the template tags included with the plugin. Please read the readme.txt file for everything you need to display images in posts. Thank you.

  10. adammuaz
    Member
    Posted 1 year ago #

    Hi Jeff,

    I followed the instruction as per link (wp-mix). but then the image showed at not only as features image also at content of post. mean it double images(same image).

    How can I set only at features image without added it at post?
    hope you understand my poor english.

    Thanks

  11. Jeff Starr
    Member
    Plugin Author

    Posted 1 year ago #

    Hi adammuaz,

    It sounds like your theme may be including the featured image, so adding the code would cause a second featured image to be displayed.. (but it's just a guess). To determine if that's the case, try using the code with the default WP theme (currently Twenty Twelve).

  12. adammuaz
    Member
    Posted 1 year ago #

    Hi Jeff,

    Thanks for reply. I did use the default theme.but it same.
    check at my test site. http://nelaye.com/blog/

    My target is to display only feature image without display image at the post. hope you can help me. thanks alot!

  13. bakivaki
    Member
    Posted 1 year ago #

    function autoset_featured() {
              global $post;
              $already_has_thumb = has_post_thumbnail($post->ID);
                  if (!$already_has_thumb)  {
                  $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
                              if ($attached_image) {
                                    foreach ($attached_image as $attachment_id => $attachment) {
                                    set_post_thumbnail($post->ID, $attachment_id);
                                    }
                               }
                            }
          }
    add_action('the_post', 'autoset_featured');
    add_action('save_post', 'autoset_featured');
    add_action('draft_to_publish', 'autoset_featured');
    add_action('new_to_publish', 'autoset_featured');
    add_action('pending_to_publish', 'autoset_featured');
    add_action('future_to_publish', 'autoset_featured');
  14. aprilbrady
    Member
    Posted 1 year ago #

    Hello Jeff,
    I have been working on getting your plugin to display images for the last 3 days w/o success. The closest I have got is getting the image to display in the user submitted post but all other post types display a duplicate of the featured image for that post.

    I realize you have supplied template tags but not sure which files they belong nor where in the php they should be placed, for I am not a php developer. I am trying to implement the example provided on WP-Mix for displaying attached images.

    My single.php file looks as so:

    [Moderator note - too much code to post here please see:
    http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

    the first bold section seems to display the first image, the next bold php (inserted from wp-mix) is inserting the 2nd image within the post. I have tried numerous things.
    Any help is apreciated.
    Thanks

  15. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    @aprilbrady - please start a new thread per http://codex.wordpress.org/Forum_Welcome#Where_To_Post - this one is marked resolved - you can do so here:

    http://wordpress.org/support/plugin/user-submitted-posts#postform

    Also, please do not post large amounts of code on the forums - use a pastebin - see:
    http://codex.wordpress.org/Forum_Welcome#Posting_Code

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.