Working with Images
One of the more convoluted topics as it relates to the web is that of images. As you are with font faces, colors, and sizes, you’re limited in the types of images you can use. Even worse, because you’re dealing with the web, bandwidth becomes an issue. For this reason, images must usually remain small resulting in degradation of quality and loss of color variation. While print publishers have a wide array of image choices including EPS, TIF, JPEG, BMP, PCX, PICT, and PNG and are not limited by size, web developers are limited to working with GIF, JPEG, and PNG and even worse must use tools to optimize the images before they’re ready for use in websites. Knowing what types of images to use can also become a factor when designing for the web. As a good rule of thumb, GIF, JPG, and PNG files should be used as follows:
GIF: GIF, which stands for Graphical Interchange Format is used for images or graphics with smaller amounts of color and graphics without much tonal range. Because GIFs read color in a horizontal line, the more color it encounters when reading, the larger the file size. Also, because GIFs read color in a horizontal line, too much color gradation can result in banding; the process of gradients being broken up into bands representing a lower dimension of color variation. GIFs also have a color table attached to them which dictates to the graphic how many colors and which color can be used in the artwork. More colors in the color table yield higher file sizes. GIFs can also store transparencies and animations but are ideal when used for flat, lower-colored graphics.
JPEG: JPEG, which stands for Joint Photographic Experts Group, is a lossy compression standard used on graphics with high tonal ranges such as photographs. This compression standard removes pixels from an image to reduce the file size. Too much compression can result in artifacts which causes the image to look blurry and unclear. As a good rule of thumb, use the JPEG file format when adding pictures to your websites that contain a lot of gradation such as family photos.
PNG: PNG, which stands for Portable Network Graphics, was introduced as a relacement to GIF a few years ago. Although Macromedia has certainly adopted the file format as standard within its Fireworks program, for the web, PNG holds a few advantages over GIF. First, color features are greater in that PNG supports alpha transparencies, which means you can have 256 levels of transparency instead of just on and off as is true for the GIF format, cross-platform control of image brightness, and two-dimensional interlacing (a method of progressive display that is similar to JPG). In addition, PNG compresses 5%–25% percent better than GIF, making this an attractive format for web developers. Of course the downside to using PNG on the web is that browser support—or more specifically down-level browser support—for PNG is simply not up to par. Even the newer versions of Internet Explorer for Windows don’t support the transparency features in PNG.
As a rule of thumb, if you’re working with flat, solid images, use GIF. If however, you’re working with images with a lot of color gradation like photographs, use JPEG. For more information on links to resources on image formats, please reference Appendix C, "General Resources."
Inserting Images into a Dreamweaver Document
The traditional Dreamweaver method of inserting an image is to use the browse-to-file method in which you select Insert, Image, browse to your file, and click Open to insert the image in the page. However, Dreamweaver also features a unique drag-and-drop method of inserting images directly from the File list. Before we jump ahead of ourselves, however, let’s review the process of inserting an image by browsing to the image file using the Select Image Source dialog. To use this method, follow these steps:
Start by placing your cursor at the top of the page (or where ever you want the image to appear).
Choose the Image option from the Insert menu or select the Image icon from the Images submenu of the Common category in the Insert bar. Either method opens the Select Image Source dialog.
Browse for the file header.gif located in the Images folder of the defined Dorknozzle site. As you can see in Figure 3.32, the filename, an image preview, and dimensions in terms of size and download time based on file size are displayed in the dialog.
Aside from simple browsing and previewing, the Select Image Source dialog also includes the ability to browse by file type, to enable and disable image previewing, and to set the file path method (document or site root relative) for the file. For our example, simply click OK. The image is inserted at the top of the page and blends in nicely with our background image.
Figure 3.32 Browse to header.gif so that you can see the filename and the image preview.
You might have to remove extra line breaks between the image and the date stamp (place your cursor just before the date stamp and press Backspace on your keyboard) to get your design to look like Figure 3.33.
Figure 3.33 The inserted header image blends in nicely with our background image.
A second option for inserting images is the drag-and-drop-from-the-File-list-panel method. By far the simplest method, you can add an image to your page by simply selecting the image from the Site Files panel and dragging it into the web page. Try this method on your own by removing the current headings (About Dorknozzle and Company Events) from the page and dragging the two subheader images (subheader_about.gif and subheader_companyevents.gif) onto the page to replace the headings. The result should resemble Figure 3.34.
Figure 3.34 Insert the two subheading images by dragging them from the File list panel onto the web page.
Formatting Images within a Document
Of course, like every other element that can be inserted into your web pages, images allow you to format numerous properties directly from the Properties Inspector. As an example, drag and drop a new image (intranetsymbolism.gif) from the File list directly into the The Company Intranet section of text so that it resembles Figure 3.35.
Immediately you’ll notice that the text doesn’t wrap nicely around the image. Setting the text alignment is just one of the many features you can do from the Properties Inspector. The callouts in Figure 3.36 highlight the complete feature set.
Figure 3.35 Drag the intranetsymbolism.gif image onto the page.
Figure 3.36 Dreamweaver’s image-based Properties Inspector includes numerous property modifications for an image.
A detailed list of each feature, moving from left to right and basic to advanced is outlined here:
Image Thumbnail: Shows a small thumbnail of the selected image.
Image Size: Displays the selected image’s size in kilobytes.
Image Name: Provides a method for uniquely identifying the selected image.
W and H: The width and height of the image are shown here. Dreamweaver allows you to stretch an image, in which case the values in these boxes will be bolded. Bolded values mean that the width and height of the stretched image do not correspond to the embedded values of the image. In fact, it is recommended that an image editor such as Fireworks be used to properly resize images.
Src: Short for source, this is the file path to the image on your computer. This value can also be an external web address, in which case the image shows broken but will display within the browser.
Link: Add a hyperlink to your image here. Hyperlinks are outlined with more detail later in this chapter.
Alt: For accessibility reasons, you’ll want to enter alternate text here. Entering alternate text is beneficial for a variety of reasons. First, it allows text-to-speech readers to present the alternate text to the disabled user since the reader can’t make out the image. Second, in Internet Explorer, a yellow tooltip appears with the alternate text when a user hovers over the image. Finally, on slower connections, the alternate text appears first while the image is loading. See Appendix A, "Accessibility," for more about alternate text.
Edit: Dreamweaver incorporates minimal editing functionality in this group of icons. For instance, you can open the selected image directly in Fireworks for editing or optimizing. You can also crop, sharpen, or change the brightness or contrast of the image directly in Dreamweaver. This integration is covered with more detail in Chapter 19, "Integrating with Fireworks." It’s important to point out that changing image properties through these options is permanent. I highly recommend that you have a backup of your image before using these features.
Class: Allows you to apply a CSS class to your image.
Image Map: Discussed with more detail later in this chapter, an imagemap is a method for creating multiple hyperlinked hotspots within a selected image.
V Space and H Space: Enter values here to create vertical and horizontal spacing in pixels around your image.
Target: When a value is added to the link text box, this menu becomes enabled. Targets, as you will see, provide a method for targeting browser windows when a user is linked from one web page to the next.
Low Src: Although you’re certainly free to generate high-quality images with large sizes (not recommended), always create a low-resolution image that you can reference here. This way, the browser loads the low-resolution image first, which the user can see as the browser finishes loading the high-resolution image.
Border: Use the border text box to add a border around your image in pixels. The color of the border depends on the default text color in the page and cannot be independently changed.
Align: Choose from these options to align the image left, center, or right on the page. Default is Left Align.
Text Align: Provides options for aligning the text around an image. Options include Baseline, Top, Middle, Bottom, Text Top, Absolute Middle, Absolute Bottom, Left, and Right. Default is Bottom.
Although we’ll end up using every property modification throughout the book, for now, format the properties of the image such that you’ve added the text Intranet Symbolism in the Alt text box and you’ve selected the Left option from the Align menu. The result resembles Figure 3.37.
Figure 3.37 Modify the name, alt text, and alignment of the image.
Image placeholders are a handy option to use while you’re developing the content of a web page and don’t necessarily have the finished images. Once you’ve inserted an image placeholder, you can easily adjust width and height dimensions to your liking. When you’re content with the dimensions, you can then select the Create option from the Properties Inspector to launch Fireworks and begin creating the image. To see how image placeholders work, follow these instructions:
Place your cursor just before the The Company Intranet text and choose Insert, Image Objects, Image Placeholder.
The Image Placeholder dialog appears, allowing you to give your place holder a name, a width, height, color, and for accessibility reasons, the option to insert alternate text. I’ll format my dialog similar to Figure 3.38.
After you click OK, the temporary image placeholder appears on the page as a solid color image similar to Figure 3.39.
Figure 3.38 Format the Image Placeholder dialog.
Figure 3.39 The image placeholder appears on the page as a solid color image.
Notice that the image placeholder includes the name and dimensions of the image. Selecting the image placeholder reveals the image placeholder-based Properties Inspector, which appears similar to the image-based Properties Inspector except for the fact that you can freely modify the width, height, and color. The image placeholder-based Properties Inspector also features the Create button which, when clicked, opens Macromedia Fireworks (assuming that that program is installed) complete with a new document, sized according to the image placeholder dimensions. We’ll be discussing Dreamweaver and Fireworks integration with more detail in Chapter 19, "Integrating with Fireworks."
To insert a rollover image within the page, follow these instructions:
Place your cursor just above the horizontal rule on the page.
Select Insert, Image Objects, Image Rollover. The Insert Rollover Image dialog appears.
Format the Insert Rollover Image dialog similar to Figure 3.40.
As you can see from Figure 3.40, the dialog allows you to insert an image name, two image states (typically these two images will have the same size and text but differ in color), alternate text, and a hyperlink. The dialog also allows you to check functionality that forces the browser to preload both images before the original is loaded. When you’ve formatted the properties, click OK.
Figure 3.40 Format the Insert Rollover Image dialog to reference our images.
The rollover image appears on the page. Now try viewing your page in the browser by choosing the Preview In Browser option from the Document bar or by pressing F12 (see Figure 3.41). In the browser, move your cursor over the new image. Notice that the original image (button_rollover1.gif) changes color to its rollover state (button_rollover2.gif).
Figure 3.41 The original image appears just above the horizontal rule.