Feature
Post

Category
Design

Are You Designing for the Smaller Screen?

I’ve been thinking quite a lot about screen resolutions and, just as importantly, screen sizes the last year or so. Being a fan of small laptops and portability, I get constantly reminded that just because I pack a decent resolution of 1024×600 pixels (or whatever), that doesn’t mean that sites looking good on a traditional screen will work on my 8.9″ one, despite them both showing as much horizontally. The way I see it, there are X aspects of smaller devices you need to at least consider when doing designs, if you want to be future proof:

  • Smaller laptops/netbooks with decent resolution, like the Asus Eee PC or any screen under 12″ basically.
  • Smaller devices with a screen size at 5-7″, sporting a resolution at 640-800 pixels horizontally.
  • Mobile phones or similar with sub-640 pixels horizontal resolution, possibly with a vertical focused screen size ratio (like the iPhone).

That last one is easiest, they more or less require special treatment. Sure, you can use Opera on a mobile phone, or Safari on the iPhone, and surf the regular full-grown web well enough, but if you want it to look good and really work for the screen, it’ll need special adaptations. That is usually a completely different version of you standard site.

The Netbook Issue

The original Eee PC

The original Eee PC by Asus

Laptops and similar larger, but still small, devices are harder. The popular Asus Eee PCs started out with a 7″ screen with 800 pixels width, that’s too small for most sites today, usually optimized for a 1024 pixel horizontal limit. Some sideways scrolling is OK, I suppose, but fluid designs or smart choices could probably at least minimize the occurrence of that. However, your traditional site could work, if you laid it out in a reasonable fashion.

It gets worse when we’re talking 5″ or 6″. The resolution won’t be 800 pixels width, it’ll be something like 640 or less. That more or less makes any site designed for 1024 pixels width a nuisance to read. Everything will look like crap, basically, and we won’t want that as a designer. Visitors on small screens like that should be getting special treatment, probably with a completely different version of the site altogether.

Add Vertical Issues

a little bit of vertical scrolling isn’t really an issue

Web designers often concern themselves with a site’s width. It is indeed important to fit everything, from content and images, to ads and links and whatnot, in the Perfect Column Setup. Compared to that, a little bit of vertical scrolling isn’t really an issue when having access to decent screen real estate. I’d venture so far to say that the blogosphere helped push this forward, it is OK to scroll down again, although advertisers still yap about being above the fold all the time. That may be as it be, but what might be a little scrolling on a normal sized screen, say 768 pixels height (1024×768 being the most common screen resolution), or perhaps even more, but it’s not as fun if we’re talking 480 pixels height in screen real estate.

It is not that there’ll be a lot of scrolling per se, it is more an issue of the small amount of actual content being displayed. Take a site like this, and a post like this. Lots of text, which is fine and pretty easy on the scrolling factor after all. But add big strong graphics, add a powerful header image, add ads breaking up the post, and you’ll get a mess. Then take that to a really small screen, and you won’t be stuck surfing the web as much as you would otherwise.

This is a tough nut, however, because while we can optimize for less width to play with, the vertical scrolling is necessary on most websites today. There are solutions, some better than others, but the one thing they have in common is that they will probably not fit the big screen, just the smaller one. In other words, while vertical scrolling isn’t as big an issue as horizontal one, you might be better of optimizing for it.

Back to the Roots: Mobile Websites

This concept would work on a mobile phone (showing The Onion anno 1997)

This concept would work on a mobile phone (showing The Onion anno 1997)

Mobile phones are getting more and more web friendly, with the iPhone leading the charge. What they have in common is that they are vertical aligned, meaning that there is more height than width to play with in your design. The fact that a mobile phone, or similar device, shouldn’t be too bulky is actually a good thing here. It means that it’ll be easier for us to do fluid designs, having text wrap from left to right, no fixed layouts or anything.

Like it was, once upon a time. Only prettier.

One thing is for sure though, these sites need special treatment. There are plugins for publishing platforms, and several services that repackage your content, and optimize it for mobile phones, and that’ll help us along the way. However, we do need to consider how we lay out these sites as well, and how we can design them to connect to their older siblings (being the traditional website, should you not be a fan of metaphor). After all, if you do have a special website for mobile devices, it should feel like a natural adaptation to the smaller screen, right?

Are you designing for the smaller screen, and what do you do to make it easier for visitors to your site using smaller devices?

Feature
Post

Category
Interviews

Cymbolism: An Interview with Mubashar Iqbal

Picking the right color for your design can be a hassle, that’s why there’s so many color schemer tools out there, of course. Recently, a slightly different one was launched by Suffolk Software, called Cymbolism. What it does is that it asks you which color you associate with a word, “love” for instance, and use that data to suggest colors based on keywords, rather than just displaying sets. I found that interesting, so I decided to interview the developer, Mubashar Iqbal, about this service.

The Interview

So what is Cymbolism, your new web app?
Cymbolism is a crowd sourcing application that that attempts to quantify the association between colors and words. Users are shown a word, and are asked to select which color they associate with that word. The user votes are tallied to quantity which colors are most associated with that word.

How would you say a designer should use Cymbolism?
When working on a new design, the creative brief usually includes a few key words that help drive the design direction.

You can lookup these words on Cymbolism, via the search functionality, and see what color people associate with those words which can provide you starting point for your designs color scheme.

Even if you decided to go against the current trends, Cymbolism will tell you what the trend is.

What sparked the Cymbolism project?
I’m really bad a picking color schemes for my web projects, so I’ve been reading a lot of articles and books on color theory, and they mention the psychology of color a lot. I started searching around the web to see if there was something more up-to-date for those associations, when I couldn’t find anything the idea for Cymbolism was born.

What are your thoughts on how colors are used in web design today?
I think the bigger sites still play it a little too safe. Most of those sites have much the same light background with a little splash of color. Even companies that have strong color associations (UPS for example) don’t make strong enough use of these colors.

What do you think govern our color choices in design? Is it all trends?
External trends do play a large role in color choices. When we see one effective use of color it usually spawns a lot of copy cats.

Same is true off-line. We still pay too much attention to what the next big color will be at the annual fashion shows, driving a lot of color choice in the print world.

Online we are able to adapt quickly and easily so people should not be afraid to try new things.

I’d like to thank Mubashar Iqbal for the interview, and urge you all to take a look at Cymbolism. Maybe it can help you in your upcoming project!

Feature
Post

Category
Publishing

Things To Consider When Using WordPress as a CMS

WordPress is first and foremost a blogging platform, but that doesn’t mean that it can’t be used for other things as well. In fact, the development of WordPress have been such that I wouldn’t be surprised to see a non-blog focused fork soon, because the necessary functionality for most web sites on the admin side of things are already there. I know, because I’ve installed and used WordPress as a content management system (CMS) for several clients the last year or so, and have had no complains yet.

“You’re crazy! Get Joomla/Drupal/Textpattern/something else instead!”

I would consider doing that, actually, if it wasn’t a fact that I know WordPress, can bend it to my will, and know that any necessary functionality I’d like to add is a mere plugin away. The fact that I’m using WordPress as a CMS for clients doesn’t mean that I don’t think that the other options out there, including TextPattern which intrigues me, are poor choices. I just know WordPress, and I know it is easy to use (as opposed to, say, Joomla) for not so familiar clients. Add a solid support for “static” content, being the WordPress Pages, and more newsy update flows controlled by the Posts, and you’ve got your needs pretty much covered for most websites online today.

Things to Consider when Choosing WordPress as a CMS

There are especially 3 things you need to consider before committing to WordPress as a CMS, and starting to plan it, as far as I can tell.

  1. Is the functionality needed covered by the WordPress core functions, and/or with the addition of (not too many) plugins? This is usually managing information pages (using Pages), and publishing news/press releases (using Posts). If I need to add a lot of custom stuff, including the custom fields, then perhaps it gets too complicated for the client.
  2. Is there a good translation of WordPress available, so that your client can get the backend in their own language? Why should my Swedish customers not have their CMS in Swedish? There is no reason, of course, and it is easy enough to install a language pack.
  3. Will my client be able to upgrade WordPress themselves, or do I need to make plans for this as well? This is true for most platforms out there, but nevertheless you’ll need to have an upgrade strategy.

The real issues present themselves when you’ve chosen WordPress as the CMS for your client project. That’s when you’ll have to think a bit outside the box, or not really, but at least peek over the blog focus edge at least.

Designing for Web Sites Powered by WordPress

In general, using WordPress as the CMS just means that you’ll design a theme as you would for a WordPress powered blog. Most of the things you need to keep in mind is what should be powering what on the site. For example, a company presentation should of course be a Page in WordPress, that way the company can edit it easily as well. With the 2.5 and 2.6 versions, the WYSIWYG editor is actually quite good as well, so there is no harm in this at all. Basically, you’ll use Pages for static content, just as you would on a blog, with the difference that Pages are your core content on the site, rather than posts, which is the core of any blog. This means that you’ll have to consider the Page hierarchy and presentation, possibly providing Page templates to control the layout a bit.

The front page of the website is another thing. These days, you can set a Page as the front page by visiting the WordPress settings (as opposed to the hacks of yonder). This is probably necessary for most traditional websites, so you’ll want to do a Page template for this particular front page Page as well, and make sure that the minimal (if any) editing that can be made from the WordPress backend should be used with caution. Breaking a front page isn’t a good thing, you know, and chances are there’s more than just text and a few images to manage, so keep the advanced stuff out of the editable part, putting them in the Page template instead.

Finally, there’s the updates, usually being company news or press releases or something similar. This content can easily be managed by using the Posts in WordPress, assigning a category for news, press releases, or whatever. This way you can have a page on the site (incidentally a Page in WordPress as well) that displays the content, and then link people to the category, possibly controlling it a bit by tweaking the category template. You could even bypass the page listing the content mentioned above, and just link the categories from the menu.

The Fiction page's sub menu

The Fiction page's sub menu

Speaking of the menu, chances are you can forget about using the WordPress functions to display Pages or categories, since that would and could mean that your client can break the design by accidentally creating un-necessary Pages or categories. I usually just put these links in the theme, and if they want to add a main category they’ll just have to contact me to do an edit. I do, however, try to make sure that adding sub-pages (i.e. Pages belonging to other Pages) will result in decent linkage on the mother Page, much like I’ve done on my fiction page over at tdhedengren.com.

Another thing you need to think about is what user priviligies your client will need to have. Sure, someone at “their side” needs to have admin priviligies, but that is probably not the general one needed. You need to consider this as well, as it is probably you that will be setting it up, and you don’t want the client to break the settings accidentally.

Checklist for Creating Web Sites with WordPress as the CMS

These are the things I tend to think about before choosing and designing a website where WordPress will be used as the CMS. There’s probably other things as well, things I just haven’t take into account since my clients haven’t had that kind of need yet. Feel free to add yours in the comments, sharing is caring after all.

  • Is there even a need for a CMS for the client?
  • Is WordPress the correct CMS? Will it fit the needs? Is the translations available for the WordPress backend good enough? How will it be upgraded?
  • Will I need to extend WordPress using plugins? Are any hacks to the core necessary, because if they are, how will I make sure that these won’t break when the core is upgraded?
  • What types of content will there be, and what should be deemed static (i.e. use Pages), and what is flowing updates (i.e. Posts)? How will I present this, and what is the main type of content?
  • How will the permalink structure be? Should it really say “category”, why not “view” or “updates” or something else?
  • Will the menu be static (i.e. coded into the theme) or controlled by WordPress (i.e. listing using WordPress tags for Pages and categories)? How could this go wrong in the future?
  • What hierarchy will the Pages have? This is important for the URL, since it should be coherent with the menu hierarchy after all.
  • How will I present sub-pages (i.e. Pages having a mother Page)? Should there be any at all?
  • Do I need Page templates for various sections? How will these work with sub-pages?
  • What categories will I use? Should the client be allowed to create new categories?
  • How will I present Posts content?
  • Do I need category templates for the various categories?

What is your experience with WordPress as a CMS, and have you anything to add to the list? Share in the comments.

Feature
Post

Category
Headline

Headline: The Designer’s List of Ad Formats

Feature
Post

Category
Strategy

New Ad Formats for Blogs Sneaking Out

When monetizing a blog most people tend to put up a bunch of 125×125 pixel ads, something of an unofficial standard. I believe this is Michael Arrington’s doing, the relaunched version of TechCrunch (which we’re seeing an updated iteration of today) introduced this in a wider scale, at least to me, and bloggers happily jumped on the bandwagon.

The concept is sound, 125×125 pixel ads aren’t obtrusive, they’re small, lightweight, but still gets the message out there.

Problem is, when putting 8 or even 10 of these in a two column layout you’ll get a cluttered block that looks worse than a set of larger ads would.

The New Format?

But maybe there’s a new format in town to gain ground. The GigaOm network runs 300×100 pixel ads in their sidebars, which looks clean compared to the 125×125 pixel ones found on TechCrunch.

sidebaradsgigaomtechcrunch.jpg

While I think 300×100 pixels is a pretty decent size, design-wise, I believe it is better to look at what default sizes are being offered and sold by ad networks. The closest one is the not so common 250×120 pixels, the half square ad (being 250×250 pixel, or sometimes 250×240 pixels, hence the “half” part). This is an ad that works well in sidebars as well, without being to obtrusive.

Incidentally, both these ad formats (300×100 pixels and 250×120 pixels) offer the advertiser a total of 30,000 pixels to work with.

The Future of Blog Ads

With blogs being more like traditional websites, we’ll see more traditional ad formats. That’s the good thing with the 125×125 pixel ads, there are several mainstream ad networks (such as Google Adsense) that will offer this size, whereas 300×100 pixels is something of an in-house creation from Giga Omni Media. I do think that 300×100 pixels is a better aspect than 250×120 pixels, but when running the latter I’ve been able to get media agencies to push out ads on my site, rather than having to have the one odd ad spot breaking my design.

Big shot blogs are already running traditional ad sizes, just look at the Gawker (Lifehacker, Gizmodo and more) and Weblogs Inc. (Engadget, TUAW and more) blogs out there. This is because they reach a mainstream audience (as opposed to the TechCrunch ones, for instance), and that mainstream advertisers used to the traditional ad formats.

Both the TechCrunch and the GigaOm network are running traditional ad spots as well, with the leaderboard ad (728×90 pixels, “the new banner” size) being the most common ground here. They are also running squares, like the 300×250 pixel ad found in GigaOm’s sidebar, and the 160×600 pixel skyscraper ad on TechCrunch.

What’s Your Poison?

Think about this when you design the ad spots for your next blog.

  • Is your crowd mainstream? If yes, look to traditional ad format.
  • Is your crowd very much web 2.0 new media-ish? Then you won’t go wrong with either, and might even get away with a custom size if your readership is enough to get the advertisers to do custom ads just for you.
  • Is your crowd the same as the blogosphere itself? Then stick to your 125×125 pixel ads for now, but be at the ready!

What ad sizes do you prefer, and why?

Feature
Post

Category
Strategy

Quick and Dirty Security Fixes Every Online Publisher Should Use

Having your site hacked is not a fun thing, I can tell you that. You might think that no one would want to hack your site, why should they? You’re wrong! Bots and scripts attack randomly, and chances are they’ve been sniffing your site already. And you know what, one of the reason for this is the amount of publishing platforms, such as WordPress or Drupal, available out there. That makes it easy for hackers to analyze the code, and find vulnerabilities. Likewise, it makes it easy for would be online publishers to get things going quick and easy.

There are a lot of things you can do to at least make it harder for these nasty things. Here are some tips.

#1: You’re Not Done Just Because the Site is Up

make sure that you won’t miss a security release

Congratulations, you installed your content management system of choice! Good for you, now get cracking on that content, will you?

Wait! Before you get carried away and forget all about the code behind the system that powers your amazing site, you need to make sure you’ve got a solid upgrade policy. And by that I mean you need to sign up for newsletters, RSS feeds from development blogs, bookmark sites, and so on, to make sure that you won’t miss a security release.

Take WordPress for example. A lot of blogs are insecure because the operators aren’t upgrading to the latest version. This goes for all online code, be it forums or pretty simple scripts. If there’s a security issue, you need to fix it. Usually that means staying up to date with the latest software, so do that!

#2: The Plugins, Extensions, Addons…

It’s not just the actual content management system that needs to be updated whenever there’s a new version released, the same goes for plugins, extensions, addons, or whatever they’re calling the extra features for your particular poison. Think about it, you’ve got this plugin that does things with your database, probably somewhat regulated, but still a vulnerability enough to make things difficult for you should it be exploited.

As a rule, keep your plugins up to date, and don’t use more than you have to. Actually, it might be a good idea to delete the ones not in use.

#3: The Username and Password Thing

The importance of a good password should be pretty obvious to us all. Don’t use a word, use both letters and numbers, use some caps, add special characters, make it at least 8 characters long… Easy tips. Today, most web apps have analyzers that look at your password and tell you if it is a strong or weak one. You should probably take that to heart.

everyone knows that every install will create this master account

However, there’s another thing here. Your username is right there in the open, after some installs. When you installed your content management system, you probably got an admin account created. That account’s username might be admin, root, master, god, or something like that. Login, create a new account with full privileges, and delete the created admin account! Why? Because everyone knows that every install will create this master account, called admin, root, god etc. - and that means that anyone who wants to hack your site already know the username to an account with full access, now they just have to hack the password.

Don’t make it easier to hack than it already is. And make sure that the privileges of accounts match what they need to do. For instance, the user who writes all the blog posts is pretty public, so don’t give it full admin access, just what you need to write, publish, and edit posts. Sure, you’ll have to login with another account whenever you want to change settings, but it is worth it.

#4: Add Security Stuff

You need to find out if your content management system of choice have any particular brilliant security features that could make life harder for hackers. Like the secret key in wp-config.php for WordPress, for instance.

This will be different from system to system, so read up!

#5: Move the System Core from Public View

consider moving the core files outside the public folders

I’m surprised that not more online platforms doesn’t do this by default. Your content management system’s core files is the ones that power the whole shebang. Without them, the site just won’t work, and that also means that if someone hack them, you’re in trouble.

First of all, consider moving the core files outside the public folders on the server. You won’t be able to move the admin interface of course, you’ll need to access that online, publicly, but the other core files might not need to be in the public folder. This makes it a little harder to mess with them, which is a good thing.

However, not all systems allow this. One solution is to put the core files in a different folder than it usually is, which won’t make it invisible online or anything, but people just surfing known URL:s won’t find it without some hassle. Not too much hassle though, this is something that is pretty easy to figure out, so don’t rely on it too much.

I hope these tips will help you make your site a little more secure. Do you have some tips of your own, or perhaps experience gained by being hacked? Then by all means share them in the comments.

Feature
Post

Category
Code

CSS: Infoboxes and Pullquotes

This is an unofficial follow-up to my previous post, titled CSS: Fun With Floating in the Grid. We'll be using some of the same mentality to make floating elements in your design, like pullquotes and boxes containing interesting facts, something I tend to call infoboxes.

Why Would I Want to Do That?

The idea with floating elements containing information or content is simple: It eases up the design. Let's say you've got a mammoth bulk of text, a truly smashing article, but it's really a heavy piece with lots and lots of text. There might not be any obvious images or illustrations to ease it up either, what to do, what to do?

So essentially, the idea is to make the design more appealing.

Simple! Use pullquotes, something magazines are really good at. They're taking quotes from the text, and floats it to the left or right, to break the flow and add some much needed space.

Informational boxes, often containing interesting facts relevant to the content, is another way to do the same thing.

So essentially, the idea is to make the design more appealing. That's why you'd wanna do that!

Pullquotes

You've probably noticed that we use pullquotes here on Devlounge. You can make your own, and add to your site, without much hassle. I suggest that you base it on the blockquote tag, which seems fitting. However, should you be running a blog, then it might clash with your present blockquote styling.

We'll solve that by adding a class called pullquote. Here's the code:

HTML:
  1. blockquote.pullquoteleft { float:left; margin: 5px 15px 15px 0; }
  2. blockquote.pullquoteright { float:right; margin: 5px 0 15px 15px; }

So should you want to have a pullquote to the right, you'll use this code:

HTML:
  1. <blockquote class="pullquoteright">this is my pullquote</blockquote>

Simple, yeah? Naturally, if you want your pullquotes to be styled differently from your blockquotes, you'll have to edit that.

Infoboxes is Just More of the Same

As you might understand by now, infoboxes are just more of the same. We'll use a div with a particular class, to float a box to the left or right.

HTML:
  1. div.infoboxleft { float:left; margin: 5px 15px 15px 0; padding: 10px; background: #eee; }
  2. div.infoboxright { float:right; margin: 5px 0 15px 15px; padding: 10px; background: #eee; }
  3. div.infoboxright h3 { margin: 0 0 10px 0; padding: 0; font-size: 14px; color: #333; }
  4. div.infoboxright p { color: #666; font-size: 12px; }

This is a very simple box, just a grey one with the same font etc. you're already using. Naturally, you'll want to complete this one with some styling that works well with your design. However, this is how you use it:

HTML:
  1. <div class="infoboxleft"><h3>This is my headline</h3><p>Here's my paragraph. I can have several.</p><p>See?</p></div>

I recommend using a different font for the content of the infoboxes, as well as using a stronger color for h3 than the actual type (managed with the p of course).

Trimming Down the Code

A quick note to wrap this up! If you really are using the ideas from the previous CSS post, then you can trim down the code for these elements a bit. Since that post wants you to have global classes for floating elements to the left and right, then you can skip the float:left; and float: right; parts, of course.

Feature
Post

Category
Code

CSS: Fun With Floating in the Grid

Sometimes for bigger design projects that will need to be pretty flexible, I tend to use several CSS classes to make it easy to maintain from a design and layout perspective in the long run. If you're a fan of grid-like design, this is most certainly things for you to consider.

Flexible Floating

To make it easier to position elements in a design, from actual content areas (like columns and sidebars), to images and boxes, I employ a set of CSS classes that can be mixed together easily enough.

The core of these classes are:

HTML:
  1. .left { float:left; }
  2. .right { float:right; }
  3. .frame { border: 1px solid #aaa; padding: 5px; }

This means that any element I've given the left class will float to the left. If I add the frame class, it will get a grey 1 pixel border, with some padding between the content and the actual border, to make it look better.

Now, to make sure that images get the necessary spacing to the left or right when being floated, I also add these additional classes:

HTML:
  1. img.left { margin: 0 15px 15px 0; }
  2. img.right { margin: 0 0 15px 15px; }

This will make sure that images floated to the left will get a 15 pixel spacing to the wrapping text to the right, and below. The same goes for images floated right, but to the left and below of course.

So how would this work?

HTML:
  1. <img src="myimage.jpg" alt="My image" class="right" />

This image will float right, with a suitable spacing to the wrapping text. Well, let's add a border to it to make it look better:

HTML:
  1. <img src="myimage.jpg" alt="My image" class="right frame" />

imagefloatdemo.gifI just add frame to the class attribute to make this happen, not hard at all. In fact, I have in the explanatory image to the right just here.

The really nifty thing, however, is that I can use the classes left and right anywhere, which can be convenient.

If you're a WordPress theme developer then you might want to add the classes alignright and alignleft to your CSS declarations. These are the default classes used by WordPress' image uploader/inserter, so it might be a good idea to support them.

Practical Layout Uses

Nothing fancy so far, right? Well, as I said, by doing it this way, I can easily arrange my layout as well. Let's say I have this 970 pixel wide design, following the grid with three columns of 310 pixels each. You might recognize the concept, it's the new Devlounge design. What I do is that I define the column, like this:

HTML:
  1. .column { width: 310px; }

No float or anything. I can also add a wide column, spanning over two columns (310x2=620 pixels), and add the spacing I have between each column in the design, being 20 pixels, bringing it to a total of 640 pixels.

HTML:
  1. .widecolumn { width: 640px; }

So let's have a wide (double) column to the left, and a single column to the right. Simple:

HTML:
  1. <div class="widecolumn left">My wide column's content</div>
  2. <div class="column right">My right column's content</div>

For clarity's sake, here's an overview of the Devlounge layout, with the columns marked:

It can be convenient to keep the float attributes free of the actual content containers. As you remember, the classes left and right are global stuff that I can pull out whenever I want.

The whole current Devlounge design is built like this, using columns and separate classes as much as I could. I could optimize it a lot more (and I am, whenever I have time), but this suited this build.

Do you use this technique, and if not, why not? Share your thoughts in the comments!

Feature
Post

Category
Code

Getting Gravatars on your Single Posts in WordPress

Gravatars are global recognizable avatars, being avatars hosted at Gravatar.com, a service run by Automattic, creators of WordPress and WordPress.com, these days. Since version 2.5 of WordPress there's built in support for Gravatars, using a template tag to display the appropriate avatar, or a placeholder. The default WordPress theme, being Kubrick renamed as default, uses it in comments, which is the common usage of gravatars.

However, with the recent redesign of Devlounge, I decided to use gravatars rather than theme-bound avatars for displaying the author's pretty face. You can't just pull the gravatar code from comments.php to do that, you need to work a bit with the template tag.

First, to display a gravatar you need to register an e-mail with the Gravatar.com service. There, you connect an avatar with the e-mail address. The key is the e-mail address, that's important to remember.

Displaying the Gravatar

The code used here on Devlounge, for the avatar on the top of the single post pages, is the following:

PHP:
  1. <?php echo get_avatar( get_the_author_id(), 40 ); ?>

So what does it mean? The get_avatar() is the WordPress call the Gravatar functionality. As you can see, I'm using the template tag get_the_author_id() to fetch the singe post's author ID, which will tell get_avatar() what e-mail to use to look for. I could use other template tags to fetch the correct e-mail, but I went with the ID one.

40 is the width and height of the avatar in pixels. 16, 32, 48 or 64 are more common uses, but 40 pixels fits the design for me.

If you wanted to, you could add a path to the default avatar URL, so that not the default one from Gravatar.com is displayed for people not having registered an avatar. In this case, I'm going with the default one because people are used to it, and when they see that a gravatar can be used, they might be more inclined to get one.

For comparison, in the comments the gravatar code looks like this:

PHP:
  1. <?php echo get_avatar( $comment, $size = '32' ); ?>

Here $comment calls the comment in question's author e-mail is used to fetch the appropriate avatar, and that one will be 32x32 pixels in size. As above, I could have added a path to a default avatar.

Feature
Post

Category
Headline

Headline: The New Devlounge

Introducing the New Devlounge