Author Image
-
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>
.autimg {
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:
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 https://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.
- The topic ‘Author Image’ is closed to new replies.