Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add Featured Image to New Topics in Frontend WYSWYG


  • goldnuggets24
    Participant

    @goldnuggets24

    Hey folks!

    Please forgive me if I’m missing something obvious. I’m looking to allow users that are creating new topics on the frontend of my BBPress-based site, to add a featured image to their topics.

    This image wouldn’t appear in their topic itself. Instead, the featured image would exist on indexed pages listing a series of topics in one area. Does this feature exist in a plugin, or is there a more customized way to add this feature?

    Thanks!

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

  • Cristi S.
    Participant

    @cristiscu

    I’d also like a featured image for forum topics.

    As it is now, the image displayed for a forum topic in a RSS reader such as Feedly is the distorted poster’s gravatar image. Which is bad.

    Any plans for this, please? Feedback would be much appreciated.

    Thanks,
    Cristian


    Stagger Lee
    Participant

    @stagger-lee

    Seems to still work.

    add_post_type_support('topic', array('thumbnail'));

    add_post_type_support('forum', array('thumbnail'));

    <?php echo get_the_post_thumbnail($post_id, 'full'); ?>


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Allowing untrusted users the ability to upload images to your site is one of those frequently requested but still pretty risky features we’ve so-far shied away from.

    WordPress (and most server configs) don’t do the type of strict file/mime type checks you’d want before enabling this, so JPGs and GIFs can embed other weird stuff and most sites would have no idea.

    There are some plugins out there to enable it, but it’s not something we’ll include with bbPress proper until WordPress (and most hosts) have a better setup under the hood.


    Stagger Lee
    Participant

    @stagger-lee

    My code (comment) is for backend, metaboxes. Or so I believe.


    kariellen35
    Participant

    @karilistermanyahoocom

    I would like my featured image to work as well. My users are not allowed to add their own topics, so this would be a feature for me to use alone. I create all of my forum topics in the back-end. There is a Set Featured Image option on forum topic pages, but it doesn’t show up anywhere.

    Thank you for your time!

    Take care,
    Kari


    kariellen35
    Participant

    @karilistermanyahoocom

    Stagger Lee, where did you add this code? Does it only bring up the image in forum or topic lists or does it appear on the forum page?


    Stagger Lee
    Participant

    @stagger-lee

    In theme functions.php or custom field with functions.php.
    It gives featured image metaboxes in backend. Then you display featured image on front as any other post type featured. See how your theme is doing this and copy/paste whole code block.

    As you need only fetaured image allowed for admins and moderators you can use this:

    add_post_type_support('topic', array('thumbnail'));
    add_post_type_support('forum', array('thumbnail'));
    /*
    Plugin Name: bbPress - Forum Icons
    Plugin URI: https://gist.github.com/ntwb/8277457
    Description: bbPress - bbPress - Forum Icons
    Version: 0.1
    Author: Stephen Edgar - Netweb
    Author URI: http://netweb.com.au
    */
    // Original Source: http://www.kristarella.com/2013/04/bbpress-forum-icons/
    add_post_type_support('forum', array('thumbnail'));
    function ks_forum_icons() {
    	if ( 'topic' == get_post_type() ) {
    		global $post;
    	    if ( has_post_thumbnail($post->ID) )
    	    	echo get_the_post_thumbnail($post->ID,'thumbnail',array('class' => 'alignleft forum-icon'));
    	 }
    }
    add_action('bbp_theme_before_topic_title','ks_forum_icons');

    I will see later what is the best way to allow all Users to set topic featured images.
    But dont see much point in it. Thousands of forum topics, thousands of images on server x all WP image sizes. Big mess.


    Stagger Lee
    Participant

    @stagger-lee

    Here is code for forum index, forum featured images, not topics:

    /*
    Plugin Name: bbPress - Forum Icons
    Plugin URI: https://gist.github.com/ntwb/8277457
    Description: bbPress - bbPress - Forum Icons
    Version: 0.1
    Author: Stephen Edgar - Netweb
    Author URI: http://netweb.com.au
    */
     
    // Original Source: http://www.kristarella.com/2013/04/bbpress-forum-icons/
     
    add_post_type_support('forum', array('thumbnail'));
     
    function ks_forum_icons() {
    	if ( 'forum' == get_post_type() ) {
    		global $post;
    	    if ( has_post_thumbnail($post->ID) )
    	    	echo get_the_post_thumbnail($post->ID,'thumbnail',array('class' => 'alignleft forum-icon'));
    	 }
    }
     
    add_action('bbp_theme_before_forum_title','ks_forum_icons');

    kariellen35
    Participant

    @karilistermanyahoocom

    Thank you so much for your help @stagger-lee! This code did work, however, it seems to only be for forum lists, which is an option already included in the bbp style pack plugin. I am trying to get the featured image to show up on the forum’s page itself (like what they do in buddypress groups) I don’t have forum lists accessible on my site so it’s not relevant to what I am doing. Thanks again for taking the time to post this tho!


    kariellen35
    Participant

    @karilistermanyahoocom

    By the way… what I did end up doing which has been a real good work-around, is use the bbp style pack single forum short code to show my forums as pages. This has been great, because it allows for much more modification! So I just added my featured image to each forum’s page.


    Stagger Lee
    Participant

    @stagger-lee

    Biggest problem with all of this is it wont allow you to edit, change featured image from front-end. Just to insert it frist, and only one, time. If Admins would be nice with giving Participants access to backend than all those problems would not exist.


    Stagger Lee
    Participant

    @stagger-lee

    Here it is.
    You hijacked topic a bit.
    I still dont understand why you use bbPress as Blog/Posts tool when WordPress is made for this. Almost as you are not so good on theming, and looking for shortcuts.

    – Make own image size
    – Change “slider” to name of own image size.
    – There is a class to center image, give it maybe some gray background for smaller featured mages. fix margins and paddings, etc…

    function ntwb_bbpress_random_single_topic() {
            global $post;
    	    if ( has_post_thumbnail($post->ID) )
    	    	echo get_the_post_thumbnail($post->ID,'slider',array('class' => 'forum-topic-featured'));
        }
    // Hook into action
    add_action('bbp_template_before_lead_topic','ntwb_bbpress_random_single_topic');
Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.
Skip to toolbar