WordPress.org

Ready to get started?Download WordPress

Forums

Frontpage-Slideshow
I hacked this to use the featured image (25 posts)

  1. mrzerog
    Member
    Posted 3 years ago #

    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.

  2. smoothman
    Member
    Posted 3 years ago #

    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';
    				}
  3. mrzerog
    Member
    Posted 3 years ago #

    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().

  4. mrzerog
    Member
    Posted 3 years ago #

    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);

  5. smoothman
    Member
    Posted 3 years ago #

    Thank You! Works perfect.

  6. enache
    Member
    Posted 3 years ago #

    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

  7. jeff_
    Member
    Plugin Author

    Posted 3 years ago #

    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 :)

  8. swf2002
    Member
    Posted 3 years ago #

    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?

  9. JohnnyFrontz
    Member
    Posted 3 years ago #

    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

  10. swf2002
    Member
    Posted 3 years ago #

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

  11. JohnnyFrontz
    Member
    Posted 3 years ago #

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

  12. JohnnyFrontz
    Member
    Posted 3 years ago #

    Any help pls!

  13. swf2002
    Member
    Posted 3 years ago #

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

  14. fbozo
    Member
    Posted 3 years ago #

    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.

  15. JohnnyFrontz
    Member
    Posted 3 years ago #

    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.

  16. fbozo
    Member
    Posted 3 years ago #

    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.

  17. swf2002
    Member
    Posted 3 years ago #

    Thanks Fbozo,

    I did exatly the same what you type. So far nearly everyhting is done, but thumbs are not showing. On their place is show again the topic of the post.

    Any ideas?

    P.S: See exaple: here

  18. swf2002
    Member
    Posted 3 years ago #

    Finaly I make it to work but I do not like few things. The hack do not use 1st attached picture if there is no thumb, also make all post topc words with no space between them for some reasson. Anyway thank for the all help. Will just use the original version.

    Many Thanks,
    Nick

  19. swf2002
    Member
    Posted 3 years ago #

    Finaly I make it to work, with some ajustments on template.php. Example of how is look like finaly can be seen here

  20. swf2002
    Member
    Posted 3 years ago #

    If somebody have still problems I can give you all files ready for use. Let me know if somebody need them.

  21. ty_ga
    Member
    Posted 2 years ago #

    @fbozo, where is template.php? I don't see it in the plugin editor with frontpage-slideshow.php

  22. ty_ga
    Member
    Posted 2 years ago #

    nvm, I got into ftp to change things around, but now the spaces between words in my titles are gone

  23. ty_ga
    Member
    Posted 2 years ago #

    Fixed spacing issue. Not sure if you guys didn't have issues b/c of a browser difference or just what, but I noticed the above code omitted a non-breaking space on line 64, replacing it with a ' ' that didn't do the trick on my site. The following code includes the non-breaking space and solves the word-spacing issue:

    $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('&nbsp;','',$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>';

    p.s. it'd be cool if we could edit posts so I didn't have to triple post

  24. You can edit posts within an hour of their initial publishing. The link is under the 'posted X ago' line by your Avatar.

  25. jeff_
    Member
    Plugin Author

    Posted 2 years ago #

    Since version 0.9.9.3.5 that I just committed, the plugin supports natively the posts thumbnails as slide image.

    Posts thumbnails are used if no image is explicitely specified on the current post.

    Here is the test made to find wich image to display :

    • Is there an explicitely specified image ?
    • Is there a post thumbnail ?
    • Is there an image on post content ? If yes, uses the first one.
    • If no image has been found, nor explicitely defined, nor post thumbnail, nor image onto the content, then uses a 1px transparent gif

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic