Chapter 9
In This Chapter
Adding images, photo galleries, and videos to your blog posts
Uploading audio files
Exploring the WordPress Media Library
Adding images and photos to your posts can really dress up the content. By using images and photos, you give your content a dimension that you can’t express in plain text. Through visual imagery, you can call attention to your post and add depth to it.
The same goes for adding video and audio files to your posts and blog. Video lets you provide entertainment through moving, talking (or singing!), streaming video. Audio files let you talk to your visitors and add a personal touch. Many bloggers use video and audio to report news and to broadcast Internet radio and television shows. The possibilities are endless!
In this chapter, you discover how to enhance your blog posts by adding images, video, and audio. And you even find out how to run a full-fledged photo gallery on your site, all through the WordPress.org software and its integrated Media Library.
You add these extras to your blog posts in the Upload/Insert area of the Add New Post page. You can add them as you’re writing your post or come back and add them later. The choice is yours!
Adding images to a post is pretty easy with the WordPress image uploader. Jump right in and give it a go by clicking the Add Media button on the Add New Post page. The Insert Media window opens and lets you choose images from your hard drive or from a location on the web. See Figure 9-1.
To add an image from the web after you click the Add Media button, follow these steps:
The Insert from URL window opens.
Type the full URL, including the http
and www
portions of the address. You can easily find the URL of any image on the web by right-clicking (PC) or Control-clicking (Mac) and selecting Properties from the menu.
The words you type here display underneath the image on your blog as a caption — if your current theme supports image captions.
Alt Text stands for alternate text, and it is what shows in a browser for visually impaired people who use text readers, or it appears when the image does not load properly for some reason. Although alternate text gives the visitors to your site a description of what the image is, adding it is also good for SEO (search engine optimization). Search engines read the alternate text (also called ALT
tags) and give search engines additional descriptive text to further categorize and define your site in listings and directories.
Whatever option you choose determines where your readers go when they click the image you’ve uploaded; you can type in a specific URL or you can select one of the three available buttons:
To add an image from your own computer’s hard drive after you click the Add Media button, follow these steps:
A dialog box opens from which you can select an image (or multiple images) from your hard drive.
The image is uploaded from your computer to your web server. WordPress displays a progress bar on the upload and displays an image options box when the upload is finished.
After an image is uploaded, the right side of the Insert Media window (see Figure 9-2) contains several image options:
Table 9-1 Styling Techniques for Image Alignment
Image Alignment |
Add This to Your Stylesheet (style.css) |
None |
|
Left |
|
Center |
|
Right |
|
WordPress automatically creates small and medium-size versions of the images you upload through the built-in image uploader. A thumbnail is a smaller version of the original file. You can edit the size of the thumbnail by clicking the Settings link and then clicking Media. In the Image Sizes section, designate your desired height and width of the small and medium thumbnail images generated by WordPress.
If you’re uploading more than one image, skip to the “Inserting a photo gallery” section later in this chapter.
The image editor (shown in Figure 9-3) options include the following tools:
You can find the Insert into Post button at the bottom of the Insert Media window (refer to Figure 9-1). The image uploader window closes, and you return to the Add New Post page (or the Add New Page page, if you’re writing a page). WordPress has inserted the HTML to display the image in your post, as shown in Figure 9-4; you can continue editing your post, save it, or publish it.
When you upload your image, you can set the alignment for your image as None, Left, Center, or Right. The WordPress theme you’re using, however, may not have these alignment styles in its stylesheet. If you set the alignment to Left, for example, but the image on your blog doesn’t appear to be aligned at all, you may need to add a few styles to your theme’s stylesheet.
I discuss themes and templates in detail in Part V, but for the purpose of making sure that you have the correct image alignment for your newly uploaded images, here is a quick-and-dirty method:
The Edit Themes page opens. All the template files for your active theme are listed on the right side of the page.
The Stylesheet (style.css
) template opens in the text box on the left side of the page.
Table 9-1 shows the styles you can add to your stylesheet to make sure that image-alignment styling is in your theme.
These styles are just examples of what you can do. Get creative with your own styling. See Chapter 13 for more information about using CSS (Cascading Style Sheets) to add style to your theme(s).
You can also use the WordPress media uploader to insert a full photo gallery into your posts. Upload multiple images once you are in the Insert Media window; then, instead of clicking the Insert into Post button, click the Create Gallery link on the left side of the Insert Media window, as shown in Figure 9-5.
This link opens the Create Gallery window, along with the multiple images you uploaded. All of the images are selected, as indicated by the check mark shown at the upper right side of the image (you can deselect any image to exclude it from the gallery by clicking the check mark).
Follow these steps to insert a photo gallery into a blog post:
The button is located at the bottom right of the Create Gallery window. This opens the Edit Gallery window.
If you would like to re-arrange the images, you can drag and drop the images to appear in the order you would like them to be displayed on your website. You can also include a short caption for each image by clicking the text box beneath each image.
Located on the right side of the Edit Gallery window, these options include:
WordPress inserts into your post a piece of shortcode that looks like this: [gallery]
.
Table 9-2 shows some gallery shortcodes that you can use to manually set the display settings for your photo gallery.
Table 9-2 Gallery Shortcode Examples
Gallery Shortcode |
Output |
|
A four-column gallery containing medium-size images |
|
A ten-column gallery containing thumbnail images pulled from the blog post with the ID 215 |
|
A three-column (default) gallery in which each image is surrounded by |
captiontag
: Change the markup that surrounds the image caption by altering the gallery shortcode. For example: [gallery captiontag="div"]
places <div></div>
tags around the image caption (the <div>
tag is considered a block-level element and creates a separate container for the content); to have the gallery appear on a line of its own, the [gallery captiontag="p"]
code places <p class="gallery-caption"></p>
tags around the image caption. The default markup for the captiontag
option is dd
.icontag
: Defines the HTML markup around each individual thumbnail image in your gallery. Change the markup around the icontag
(thumbnail icon) of the image by altering the gallery shortcode to something like [gallery icontag="p"]
, which places <p class="gallery-icon"></p>
tags around each thumbnail icon. The default markup for icontag
is dt
.itemtag
: Defines the HTML markup around each item in your gallery. Change the markup around the itemtag
(each item) in the gallery by altering the gallery shortcode to something like [gallery itemtag="span"]
, which places <span class="gallery-item"></span>
tags around each item in the gallery. The default markup for the itemtag
is dl
.orderby
: Defines the order that the images are displayed within your gallery. Change the order used to display the thumbnails in the gallery by altering the gallery shortcode to something like [gallery orderby="menu_order ASC"]
, which displays the thumbnails in ascending menu order. Another parameter you can use is ID_order ASC
, which displays the thumbnails in ascending order according to their IDs.<span>
tags in your CSS stylesheet.
The <span>
tags create an inline element; an element contained within a <span>
tag stays on the same line as the element before it; there is no line break. You need a little knowledge of CSS to alter the <span>
tags. Click the Editor link in the Appearance menu on your WordPress Dashboard to edit the stylesheet for your theme. Here’s an example of what you can add to the stylesheet (style.css
) for your current theme:
span.gallery-icon img {
padding: 3px;
background: white;
border: 1px solid black;
margin: 0 5px;
}
Placing this bit of CSS in the stylesheet (style.css
) of your active theme automatically places a one-pixel black border around each thumbnail, with three pixels of padding and a white background. The left and right margins are five pixels wide, creating nice spacing between images in the gallery.
style.css
) template.Figure 9-6 shows my post with my photo gallery displayed, using the default image.
Some great WordPress plugins work in tandem with the WordPress gallery feature. Check out Chapter 10 for information on how to install and use WordPress plugins in your blog.
Whether you’re producing your own videos for publication or want to embed other people’s videos that you find interesting, placing a video file in a blog post has never been easier with WordPress.
Several video galleries on the web today allow you to add videos to blog posts; Google’s YouTube (http://youtube.com) is a good example of a third-party video service that allows you to share videos. To add a video from the web, click the Add Media icon and then click the Insert from URL link and follow these steps:
Type the full URL, including the http
and www
portions of the address. Video providers, such as YouTube, usually list the direct link for the video file on their sites; you can copy and paste it into the URL text box.
Giving a title to the video allows you to provide a bit of a description of the video. It’s a good idea to provide a title if you can so that your readers know what the video is about.
A link to the video is inserted into your post. WordPress doesn’t embed the actual video in the post; it inserts only a link to the video. Your blog visitors click the link to load another page where the video can be played.
The previous steps give you the ability to insert a hyperlink that your readers can click and view the video on another website (such as YouTube.com). WordPress also has a nifty feature called Auto-Embed that automatically embeds videos within your posts and pages when you simply type the URL for the video into the body of your post or page.
WordPress automatically detects that a URL you typed in your post is a video from YouTube (for example) and automatically wraps the correct HTML embed code around that URL to make sure that the video player displays in your post (in a standards- and XHTML-compliant way).
You do not need to do anything to enable the Auto-Embed feature — this is built into WordPress and it does it for you automatically.
To upload and post to your blog a video from your computer, click the Add Media icon on the Edit Post or Add New Post page. Then follow these steps:
An Open dialog box opens.
You return to the file uploader window in WordPress, which shows a progress bar while your video uploads. When the upload is complete, a box containing several options drops down.
It provides a direct link in your post to the video file itself.
WordPress doesn’t embed a video player in the post; it inserts only a link to the video.
Audio files can be music files or a recording of you speaking to your readers. Audio adds a nice personal touch to your blog, and you can easily share audio files on your blog through the use of the Upload Audio feature in WordPress. After you’ve inserted an audio file in your blog posts, your readers can listen to it on their computers or download it onto an MP3 player and listen to it while they drive to work.
Click the Add Media icon on the Edit Post or Add New Post page and follow these steps to upload an audio file to your blog post:
An Open dialog box opens.
You return to the file uploader window in WordPress, which shows a progress bar while your audio file uploads. When the upload is complete, a box containing several options drops down.
In the Attachment Display Settings drop-down menu, you can select Embed Media Player (embeds the audio file in an audio player on your site); Link to Media File (inserts the title of the audio file, linked to the file itself); or Link to Attachment Page (inserts the title of the audio file, linked to a post containing the file).
The audio file is inserted into your post using the method you selected in Step 6.
Some great WordPress plugins for audio handling can enhance the functionality of the file uploader and help you manage audio files in your blog posts. Check out Chapter 10 for information on how to install and use WordPress plugins in your blog.
If you’ve been running your blog for any length of time, you can easily forget what files you’ve uploaded with the WordPress uploader. I used to have to log in to my web server via FTP and view the Uploads folder to see what I had in there. Now, the WordPress Media Library makes it very convenient and easy to discover which files are in your Uploads folder.
To find an image, video, or audio file that you’ve already uploaded using the file uploader and use that file in a new post, follow these steps on the Add New Post page:
You see all the files you’ve ever uploaded to your blog with the file uploader feature; see Figure 9-7. Files you’ve uploaded through other methods, such as FTP, are not displayed in the Media Library.
The correct HTML code is inserted into the post text box.
If you want to view only the files you’ve uploaded and don’t need a particular image or file for a new post, click the Library link in the Media menu, which opens the Media Library page. The Media Library page lists all the files you’ve ever uploaded to your WordPress blog. By default, the page displays all types of files, but you can click the Images, Audio, or Video links to specify which file type you want to see; see Figure 9-8.
You can do the following tasks on the Media Library page:
kittens
.3.142.197.212