WordPress.org

Support

Support » Plugins and Hacks » Frontpage-Slideshow » [Plugin: Frontpage-Slideshow] I hacked this to use the featured image

[Plugin: Frontpage-Slideshow] I hacked this to use the featured image

  • I just thought I would let you know that I successfully hacked this plugin to use the wp 3 featured image, as well as displaying the thumbnail in the buttons.

    here’s a screenshot:
    http://cl.ly/b620c40e58d9703ac75d

    Almost everything is done in the template, but i had to modify the core frontpage-slideshow.php just a bit, to get it to add the post_id to the array that it supplies to the frontpageSlideshow_TPL(), as well as changing the default post_thumbnail size to the size of my buttons.

    here’s the change to line 81 of frontpage-slideshow.php v 0.9.9.3.4

    $fsentries[] = array('title' => $title.' ', 'image' => $image, 'comment' => $comment.' ', 'button-comment' => $buttoncomment.' ', 'link' => $link.'&nbsp', 'post_id' => $fspost->ID);

    and here’s the new code in the template.php, line 54

    $fscontent .= '<li id="fs-entry-'.$id.'" class="fs-entry">';
    if(has_post_thumbnail($entry['post_id']))
    {
        $fscontent .= get_the_post_thumbnail($entry['post_id'], 'large', array(
            'class' => 'fs-skip fs-img',
            'id' => "fs-entry-img-$id"
        ));
        $fscontent .=  get_the_post_thumbnail($entry['post_id']);
    }
    else $fscontent .= '<img id="fs-entry-img-'.$id.'" class="fs-skip fs-img" alt=" " src="'.$entry['image'].'" />';
    $fscontent .= '<div id="fs-entry-title-'.$id.'" style="position: relative; top: -44px;" class="fs-title">'.str_replace(' ','',$entry['title']).'</div>';
    $fscontent .= '<span id="fs-entry-comment-'.$id.'" class="fs-skip">'.$entry['comment'].'</span>';
    $fscontent .= '<span id="fs-entry-link-'.$id.'" class="fs-skip">'.$entry['link'].'</span>';
    $fscontent .= '</li>';

    finally, you have to change the post_thumbnail size to match your buttons in your functions.php file
    set_post_thumbnail_size(x, y, true); // Where x is the width of your buttons and y is the height

    Cheers, and thanks for the plugin.

Viewing 15 replies - 1 through 15 (of 24 total)
  • Hey, Looks great!

    How did you managed to upload a featured image in a post en than let it show up in the frontpage-slider? Can you clarify this for me? Thanks in advance

    I think that this is the specific code that should be adjusted:
    (from the frontpage-slideshow.php)

    $image = get_post_meta($fspost->ID,'fs-picture',true);
    			if ($image == '') { // if no image : use the first image on the post
    				$image = $fspost->post_content;
    				if (preg_match('/<img[^>]*src="([^"]*)"/i',$image,$matches)) {
    					$image = $matches[1];
    				} else {
    					(is_ssl()) ? $url = str_replace('http://','https://',get_bloginfo('url')) : $url = str_replace('https://','http://',get_bloginfo('url'));
    					$image = $url.'/wp-content/plugins/frontpage-slideshow/images/one_transparent_pixel.gif';
    				}

    the only change you need to make to frontpage-slideshow.php is on line 81, as I showed up there. The idea is that you need to send the post ID to frontpage_slideshow_TPL() along with all the regular slideshow info. You then make a new template with a different frontpage_slideshow_TPL function, which takes the supplied ID, and from there, it’s a simple matter of using get_the_post_thumbnail().

    also, my code up there for line 81 is a tiny bit wrong. The links would not work because I mistakenly appended a space to the end. it should read:
    $fsentries[] = array('title' => $title.' ', 'image' => $image, 'comment' => $comment.' ', 'button-comment' => $buttoncomment.' ', 'link' => $link, 'post_id' => $fspost->ID);

    Thank You! Works perfect.

    i to subscribe to thank you very much for this hack
    but do you think that it can have 2 images one for the buton and one for the post, i mean that i want to use another image for the button, in fact is the same image but a custom part of it, and another one for the big post slider
    let say the image in the post could be the big one and the image from the featured image to be the button
    i hope i was clear and i hope that it can be done it, thanks a lot

    Plugin Author jeff_

    @jeff_

    All that is simple to add, if you know how to code, its easy, if you don’t know… wait for some one to do it 🙂

    I try to change the codes how you describe but have problems showing thumbs after when I do all changes. Can you please provde your full files frontpage-slideshow.php, template.php please?

    Also you requare changes in functions.php file but this is not in the dir of that plugin… can you please help?

    I am having the same problem. I replace the code at frontpage-slideshow.php, template.php and at function.php. And the result is to have pic one down the other in my homepage

    JohnnyFrontz: where you find function.php file for edit?

    swf2002: in my theme folder. But still does not working!

    Any help pls!

    It is look like nobody from the members above read the forum… I will be happy if somebody help too

    Excellent!
    A couple of minutes ago I was on this path but couldn’t figure it out (still a programmer wanna-be).

    MrZerog Thanks you for your hack!

    JohnnyFrontz and swf2002

    1. You have to replace from the line 54 for it to work. It’s basically the same code with a couple of tweaks.

    2. function.php should be part of your theme, not the plugins.
    /wp-content/themes/your-theme/function.php

    Hope that helps and isn’t too late.

    fbozo thanks for the answer. I have to change the line 54 from template.php and the function.php from theme folder. The frontpage-slideshow.php not? Cause if I change and the frontpage-slideshow.php doesn’t work.

    JohnnyFrontz
    You have to change 3 files
    1. wp-content/plugins/frontpage-slideshow/frontpage-slideshow.php

    In line 81 replace the similar with
    $fsentries[] = array('title' => $title.' ', 'image' => $image, 'comment' => $comment.' ', 'button-comment' => $buttoncomment.' ', 'link' => $link, 'post_id' => $fspost->ID);

    2. wp-content/plugins/frontpage-slideshow/templates/your-template/template.php

    In line 54 replace the similar with

    $fscontent .= '<li id="fs-entry-'.$id.'" class="fs-entry">';
    if(has_post_thumbnail($entry['post_id']))
    {
        $fscontent .= get_the_post_thumbnail($entry['post_id'], 'large', array(
            'class' => 'fs-skip fs-img',
            'id' => "fs-entry-img-$id"
        ));
        $fscontent .=  get_the_post_thumbnail($entry['post_id']);
    }
    else $fscontent .= '<img id="fs-entry-img-'.$id.'" class="fs-skip fs-img" alt=" " src="'.$entry['image'].'" />';
    $fscontent .= '<div id="fs-entry-title-'.$id.'" style="position: relative; top: -44px;" class="fs-title">'.str_replace(' ','',$entry['title']).'</div>';
    $fscontent .= '<span id="fs-entry-comment-'.$id.'" class="fs-skip">'.$entry['comment'].'</span>';
    $fscontent .= '<span id="fs-entry-link-'.$id.'" class="fs-skip">'.$entry['link'].'</span>';
    $fscontent .= '</li>';

    3. wp-content/themes/your-theme/functions.php

    Add if you don’t have it already (some themes have this activated) at the bottom

    set_post_thumbnail_size(x, y, true); // Where x is the width of your buttons and y is the height

    Wish that this helps you.

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘[Plugin: Frontpage-Slideshow] I hacked this to use the featured image’ is closed to new replies.
Skip to toolbar