WordPress.org

Ready to get started?Download WordPress

Forums

Author Image (4 posts)

  1. satoshi
    Member
    Posted 10 years ago #

    I couldn't find this anywhere in the wiki, nor on these forums, so I decided to post it here:
    I've devised a relatively simple hack that involves very minor changes to the index.php and wp-layout.css
    First, the index.php, where you see this line:
    <div class="storytitle" id="post-<?php the_ID(); ?>"><?php the_title(); ?></div>, add
    <img class="autimg" src="authors/<?php the_author() ?>.gif"> so that it looks like this now:
    '<div class="storytitle" id="post-<?php the_ID(); ?>"><img class="autimg" src="authors/<?php the_author() ?>.gif"><?php the_title(); ?></div>
    That will then try to display an image under the "authors" directory with the author's, to whom the post belongs, name with the .gif extension.
    After that, make said folder and put images in there corresponding to the author. If an author does not want an image, just upload a 1px by 1px transparent gif and it will only display the border (i haven't figured out how to use an if statement to find whether or not the image exists and then to display it or not, if someone can help me with this, it'd be greatly appreciated).
    As for the CSS, just add this to it:
    .autimg {
    float:right;
    border:1px solid #556677;
    }`
    Modify that to your liking, and you've got a simple hack that displays a different author image depending on who posted. There's an example at http://trashfolder.org/ffxi/new.php. Mind you, however, that the current layout/design of that page is absolutely horrible at the moment and is a severe work in progress, but it gives an idea of the author icon. Satoshi's has a little dude from Graal, and site admin has the transparent gif (apparently not 1px by 1px, though).
    If someone could help me with the if statement that checks whether the author.gif exists or not and then displays/doesn't display the corresponding code, that'd be greatly appreciated.

  2. benramsey
    Member
    Posted 10 years ago #

    On second thought, that doesn't work so well because the_author() echoes the text rather than returning it. So, you can't use the above method to check to see whether the file exists; it won't work.

  3. wellard1981
    Member
    Posted 9 years ago #

    I've developed a hack which displays the author image (if it's available), see http://www.wellardsworld.com/content/wphacks#wp-userphoto.php for more details.

  4. satoshi
    Member
    Posted 9 years ago #

    Heh, late reply to my own topic, but if the image doesn't exist, it'll simply not display it.

    Er.. Crap, I see. There are still people who use Internet Explorer. It'll display the nasty red X box. Forgot about that.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.