Join James Williamson for an in-depth discussion in this video Modifying image properties, part of Dreamweaver CS5 Essential Training.
One of the constant challenges in working with sites built around clean HTML and CSS is precisely what to control with CSS and what to control through the HTML? Working with images is a particularly great area, since there are many properties that you can control, either through CSS or directly through the image itself. In this movie, we are going to discuss the image properties you can change using Dreamweaver's Properties Inspector and the benefits of controlling these properties through the Image tag or through CSS.
So here we have the explorers.htm file opened up, and I want to scroll down just a little bit to examine this image on our page. So I am going to select the image of the couple at the bistro, and I am going to turn our attention down here to the Properties Inspector. So there is a lot of stuff going on here, and if you are looking at the stuff for the first time, it can almost be a little overwhelming, like what is all this stuff and what can I do with it, and what should I be doing with it? Well, let's just go through it one piece at a time. First off, in the upper left -hand corner we have an ID.
Now, just beside that you'll notice that we have a width and height. Now to be honest, you really should never change this, and you basically want to make sure that when you save the image out it's the width and the height that you need it to be. But Dreamweaver does give us those options. In fact, Dreamweaver gives us these handles, and we can grab those, and we can make that image as wide and as tall as we want it to be. I don't think we help the image out there. There is an old saying: Just because you can, doesn't mean you should, and that certainly is applicable here.
But look what Dreamweaver did for me though. It says, "Hey you've changed this, and you've changed this." How do I know that? Because the text is bold. So if you see a measurement there that doesn't look quite right, that's a clue to you that maybe one of your other teammates or somebody or maybe even you, the night before when you were working really late, changed that without meaning to. Well, Dreamweaver gives us another nice little tool as well. We have a little Refresh button there and if I click that, it's going to reset that image to its proper size, sort of undoing that damage that I just did. So you want to be kind of careful about that.
We also have, right beside, that a source property. Now, I want to point out exactly what the Source property does for you by switching to a Split View, so that we can see both the Image tag and the image at the same time. Images are controlled through the use of this Image tag, img, and this attribute in the Properties Inspector, Source, is the Source attribute right here on our tag. The Source attribute is telling the browser or user agent where to go find that image. So in this case, it's saying go look in the Images directory and find lunch.jpg.
So changing this through the use of the Point to File icon or typing something in or placing an image on the page is going to actually set that attribute within the code. We also have a Link attribute, so if you wanted to make this image a clickable link that people could click on to go to another page, you would enter that information there, and we have a Target. Right below that, the Target property is linked to the Link property. If you wanted to, say, open up the page that you are linking to in a new browser window or a new tab, you could use the Target pulldown menu to do that.
We also have our alt text. We've talked about that in some previous movies, but if you want to manually set that alt text, you could highlight that there and then choose that. We also have some editing options here. Now we've covered these in some of our previous movies, but very briefly if you want to edit this image, you can simply click on this icon to edit it in the program of your choice, in this case Photoshop. But we also have an Edit Image Settings icon that we haven't really talked about yet. If you ever need to re-optimize an image, maybe something was saved at too high of a compression, or maybe an image was saved and it's just a little too large, you can click that, and you're going to get your Image Optimization dialog box that comes back up, and you get to choose which settings you like this image to have.
You need to be very cautious about using this, especially if you're working with JPEGs. Remember, JPEGs are optimized every single time they are saved. So you are going to be throwing image data away. So you are not going to be improving the image quality of something by doing this, you are, in most cases, going to be degrading the image quality. So typically this is only done if you really need to save file size. My advice is to go ahead and make sure you export the graphic out of Photoshop or whatever program you are working in, the size you need it originally, and that way you'll avoid having to worry about that.
Now, turning our attention to the bottom row, right here, we see controls for making an image map. Image Maps are not as widely used online as they were say 5, 6, 7, 10 years ago. But they are a viable way of creating areas within your image that can be linked. So for example, if I wanted to highlight this glass of lemonade and make it link out to one page and highlight her hat and maybe link out to a page about hats, I could certainly do that by using this Image Map and drawing hotspots around those link areas.
We have a property called V Space, which is vertical space, and H Space, which is horizontal space. This image is currently just sort of floating right in our text, and it shows us something about images. There are inline level elements and browsers and user agents, just flow them right in with the rest of your copy. In this case, when your image is so much larger than your text, it gives you a very weird layout. So V Space and H Space are going to help you do things like move the text away from the image. For example, I could go into H space here and type in 10, and it would give me 10 pixels of space.
It would push that text away from that. Now, if you were paying attention, you've probably also noticed that it pushed the image away from the edge of the container as well. So H Space goes horizontally on both the left and the right side. We've got 10 pixels worth of space on both of those sides. Vertical Space would give a space above and below. So we don't get to pick one side over the other. It just kind of happens to both sides. We have a little dialog box here for Original and if I have a Photoshop image that is the original source file for that, I can let Dreamweaver know about it within that dialog box, and then if I click to edit the image, it will instead open up the Photoshop file rather than the JPEG.
That can save you a lot of time and effort from having to go hunt down and open up that Photoshop file yourself. The last couple of settings I want to show here. Border, we can enter in a border for a graphic. Let me show you what I mean. If you do that, you're going to get sort of that three-dimensional sort of grooved border that browsers put in, and honestly it's going to be up to the browser. Chrome has got its own version of the border. Firefox has its own version of it. So you're not really controlling exactly what border type you want. You're not in control of that. That's why I would recommend, if you really want to border around your graphic, use CSS to do that.
If you are going to make a link out of this graphic, it might be a good idea to come in and type in Border 0. That way, you won't have any type of decoration or blue border around the image. Some browsers use that as a default. If an image has a link, it'll put a blue border around the image without you asking it to. We also have a couple of tools here that allow us to crop our images, allows us to sharpen our images, change the brightness and contrast, and these are kind of neat tools. But again, I'm of the mind that you should probably do this in a program that's designed to do it, such as Photoshop.
But notice if I choose to increase the brightness and contrast of this image, I can go ahead and increase the contrast, and make some fairly dramatic changes to my image. Maybe that's what I want to do, maybe that's not what I want to do, but frankly I don't think that this is the right place to do that. You should probably open that image back up in Photoshop or Fireworks, tweak it, do what you need to do to it, save it back out again, and come back in Dreamweaver. But for small changes or maybe changes where you don't have access to the software, it's not a bad tool to use.
Now, I am going to go ahead and click OK here, but the thing I want you to remember is that I have just made a permanent change to that image. The moment I saved this page and closed it, I've literally changed that JPEG graphic. So if it's being used on any other page, I've changed it there as well. Finally, I want to talk about the Alignment option down here. This confuses a lot of people, because if we grab this pulldown menu, you can see we have a lot of options. We have Baseline, Top, Middle. What is all this stuff? Well, typically, this was created to deal with image captions, a single line of text. So if chose Middle, for example, notice that the line of text that it is a part of aligns to the very middle of the graphic, however, the rest of text doesn't wrap around it at all.
But if you do want to have the text wrap around image, you do have a couple of choices with this. If I go to the Align pulldown menu and I choose Left, notice that the image aligns to the left of the text. If I choose Right, the image aligns to the right of the text. Here the horizontal space is helping us keep the text away from the image. So if I take the back down to 0, you can see the text is budding up right against the image. But of course, the downside of this, and I'll go back to using 10 here is that it moves the image away from the edge of the container as well. So you get it on both sides. So that is one way to achieve that look.
Now what's wrong with doing that in HTML versus CSS? Nothing. It's a personal choice. However, it's not as flexible. By saying, Image Align, Right, we are flowing our text exactly where we want, but we have very little control over the spacing of this and how it's placed within the text. You can see we have our H and V Space properties, but it's really pushing the image away from edge of container too, and that's really not what I want at all. So I am going to remove my H Space, and I am going to take my alignment back to Default, because there is another way to do this, and it would be modifying our images through CSS.
If I select this graphic, I have one more option available to me here in the Properties Inspector. I have this little Class pulldown menu. I am going to grab that, I am going to go up, and I am going to choose Article Image and sure enough, it aligns over to the right just like I wanted it to. It gives me enough padding, 16 pixels worth off of this, so that the text isn't budding right up against the image, and it keeps it aligned to the right edge, which is exactly what I want it to do. So in this case, Cascading Style Sheets were a better choice than modifying the image HTML properties themselves.
So how do you style images through CSS? Well, we are going to cover that in our next exercise but for now, I think you can see that there are a ton of properties you can change once an image has been placed on the page. Now, based on what the focus of your CSS is, you may want to control a lot of those properties through your styles rather than through the image itself. In the long run, that's going to create less work when modifying similar image properties across the entire site. Be extremely careful when resizing or editing the image from the Properties Inspector.
The image quality may degrade, so you want to test that thoroughly before committing to any changes.
- Defining and structuring a new site
- Creating new web documents from scratch or from templates
- Adding and formatting text
- Understanding style sheet basics
- Placing and styling images
- Creating links to internal pages and external web sites
- Controlling page layout with CSS
- Building and styling forms
- Reusing web content with templates
- Adding interactivity
- Working with Flash and video