• Aucun résultat trouvé

Featured Images

Dans le document Matthew MacDonald WordPress (Page 196-200)

Instead of simply including a picture in a post, you can designate it as a featured image. A featured image represents a post, but it doesn’t actually show up as part of the post content. Instead, its role varies depending on the theme you use. Some themes ignore featured images altogether, while others have devised ingenious ways

PicTures replace the site header on your home screen. Figure 6-11 shows how this works.

Figure 6-11 When you read this post in single-post view, the featured image (some green tea leaves) temporarily replaces the site header. This works even though the picture doesn’t actually appear anywhere in the post.

 NoTE  The header-replacement trick works only if the featured image is at least as big as the header image.

If your featured image isn’t as wide, WordPress won’t display it at all on the single-post page, nor will it explain the image’s perplexing absence.

The changing-header trick is interesting, but the real magic is the way that different themes can use featured images in completely different ways. Many themes use them to promote posts—for example, to highlight them in some sort of scrolling banner or gallery. Depending on the theme, this detail might be a built-in part of the home page, or it might rely on a theme-specific widget.

PicTures WordPress sites. It uses a featured image slideshow on the home page. This slider automatically grabs all the posts in the category named Featured (which you must create). It then shows the featured image for each of the posts, one after the other.

The title of the post that’s current being shown in the slider

These two bullets indicate that there are

two featured images The slider is transitioning to

a new featured post Figure 6-12

The Brightpage theme uses a slider—a graphical banner that shows the featured images for your most timely or important posts. Each featured image appears for about 5 seconds, and then the slider changes to the next image by using a slick transition effect (a fade, a blend, or a slide, which gives the slider its name).

Visitors can click the featured image to view the corresponding post, or scroll down the page to see more posts.

The nice thing about the Brightpage theme is that it makes it easy for you, the site designer, to choose what posts appear in the slider. When you create a new post that you want to appear in the slider, simply assign it to the Featured category (in addition to whatever more meaningful category you’re already using to classify your post). After some time passes and you decide that the post is no longer as important, go to the Edit Post page and remove it from the Featured category.

You can assign just one featured image to a post. To do so, you need to be in the Add New Post or Edit Post page. Then follow these steps:

1. Find the Featured Image box in the bottom-right corner of the page. Click the “Set featured image” link.

PicTures earlier (Figure 6-7).

2. Upload the picture you want to use.

You can upload your featured image by dragging it into the “Drop files here”

area, or by clicking Select Files and browsing for it.

3. Add the image information.

Once you upload a pic, the Set Featured Image window expands so you can add details about the image (title, alternate text for screen readers, caption, and so on). How much of this information WordPress uses in your post depends on the theme you chose, but it’s worth supplying the info just in case.

4. Click Edit Image, take a moment to scale and crop your picture, and then click Save to make your changes permanent.

When you insert a standard image into a post, you get the chance to size it.

But if you use a theme that automatically displays featured images, you don’t have this control. If you upload a big picture, it’s possible that your theme will automatically crop out a large part of it. (The Brightpage theme does this, for example.) To prevent this, you need to scale the picture down before you up-load it, using an image editor like Photoshop Elements, Windows Photo Gallery, Picasa, or the Mac’s Preview program. To find the right dimensions, you need to experiment or scour the documentation for your theme. (Self-hosters: search for your theme at http://wordpress.org/extend/themes, and then click your way through to the “Theme Homepage” link. WordPress.com users: search for your theme at http://theme.wordpress.com.)

5. Click the “Use as featured image” link that appears underneath the picture information, and then close the Set Featured Image window by clicking the X in the top-right corner.

If you decide at some future point that you don’t want this picture as your post’s featured image, just click the “Remove featured image” link in the Featured Image box.

6. Publish your post (or update it, if you had already published it).

Remember, some themes don’t use featured images at all. If you use such a theme, you may not even know that your post has a featured image, because your theme never displays it.

 NoTE  Featured posts are interesting because they rely on the interplay between WordPress features and theme features. WordPress simply defines the concept of the feature (in this case, featured images), and the theme decides how to exploit that concept, opening a wide, uncharted territory of possibilities. The same idea underpins many other WordPress features. For example, later in this chapter you’ll see how WordPress defines the concepts of post excerpts (page 196) and post formats (page 177), but allows themes to use them in a variety of clever ways.

Dans le document Matthew MacDonald WordPress (Page 196-200)