PDA

View Full Version : Wordpress image locator fix



the goat
03-12-2009, 11:16 PM
So I have a couple of sites where the image locator in posts just never worked for me, they were always on the left side unless I put my own html commands in. (which was hugely annoying because if I ever switched out of html they would disappear) I had been looking for the fix for a while and I finally came across what I was looking for. I thought I would share it in case anyone else was having the same frustrations.

I simply added this to my .css file and it now works like a charm:

img.centered, .aligncenter, div.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}

img.alignright {
padding: 4px;
margin: 0 0 2px 7px;
display: inline;
}

img.alignleft {
padding: 4px;
margin: 0 7px 2px 0;
display: inline;
}

.alignright {
float: right;
}

.alignleft {
float: left;
}

vangogh
03-12-2009, 11:48 PM
The problem was likely theme related then. All those classes are part of the default WordPress theme and I guess that's how the image locator sets things. Good to know. I usually use floatright, floatleft or just right and left in my css, but in themes I'm going to stick with alignright, alignleft, etc just to not break someone's posts.

the goat
03-13-2009, 02:11 AM
Yeah not sure why anyone would remove that for a theme. Of the last five I have used, the image locator didn't work with four of them and I had to put that in there.

vangogh
03-13-2009, 11:29 AM
The problem is that the image locator shouldn't be tied to those classes. Most coders will have their own name for the classes. alignleft wouldn't be my first choice or at least hasn't been in the past. I've used left and floatleft to do the same thing. The align part is how WordPress has done things, but the functionality really shouldn't be tied to any specific class name.