- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
position:relative in CSS was probably added because it fixed a heap of old (v<=6) Internet Explorer rendering bugs.
Admin
But we don't fix rendering bugs in old versions of IE, it only encourages them. Let them update or suffer with their incorrect life choices.
Admin
A lot of companies held on to IE6 way too long because of in house web apps that depended on its quirks.
Admin
Key words here: "mid-2000s."
The real WTF here is PHP ducks
Admin
Also, the explanation for the WTF is wrong.
For each row, it would read the image ID from the database. Then it would read it in memory to get height and width, and with that information it would create its attributes. Without knowing the rest of the configuration, we don't really know if this is even a real WTF. With some aggressive caching this may hit the database only once per client.
Admin
At least they didn't use ImageMagick...
Admin
But if you don't do it this guy's way, it's too easy for people to steal your CSS code!!!
Admin
So what was the performance improvement, if any? Inquiring minds want to know.
Admin
To query the database or not query the database (for supposedly static data)... That is just not a question!
Admin
ImageMagick might well have been faster, although the memory usage probably would have been a big higher...
Admin
That's got to be a pretty huge css file once it's all done. I bet just loading it drags up pageload time significantly.
(PS, there should be a <?php just before the query($sql);.)
Admin
The <?php is there, at least in the page source. But the "<" isn't escaped, so the browser thinks it's a tag.
Admin
@LH:
Sorry, I'm struggling to see how your explanation differs from the one in the article. You both agree that it's reading the image ID (and filename) from the database, then loading the image into memory and creating the attributes and the rest of the CSS style.
Perhaps you read the article as implying that the image data itself is being read from the database? To me the article text is ambiguous on this point but I can see how you might have interpreted it that way.
I do have to take issue with one sentence in your comment though: "Without knowing the rest of the configuration, we don't really know if this is even a real WTF." Yes, yes we do.
Admin
Huh. 24 hours later and I just figured out what PHP ducks were.
Admin
There's actually something to be said for explicitly setting the dimensions of your images in the stylesheet - without that, you get some funky layout jumping as the images are loaded, and if one is missing your layout can get really off.
However, it really should be done during a build step, not on the page load.
Admin
Please explain. "duck" is a common auto-replace for a certain swear word, but that doesn't make sense. "sucks" works, but...
Admin
Little Donald Tables…
Admin
img[width=800][height=600]
Html only, no Css required
Admin
There is something to be said to read out all image meta-information from a database. You could probably even make a case for creating unique CSS classes for them. Presumably there are use cases where a dynamically generated CSS file makes sense, so that whole "The CSS linked to a PHP file" is not TRWTF either in my opinion. But needlessly doubling your static file-reads? Well, that's got to be at least a bit of a WTF.
Admin
@Worf: @LH is ducking, to avoid being punched for saying that PHP is TRWTF.
Admin
I've a 400+ KB CSS file, part of an extension though. Slows down rendering in Thunderbird, Firefox is fine with it.
Admin
WTF TDWTF... Auto dimensions help for matching the size of a css background image how exactly? Relative position was probably needed for some case too. And the code sample is missing the opening php tag.
This site is failing worse and worse every day...
Admin
You know, even with languages like PHP, you can just read a file's metadata without loading it fully into memory. On Linux systems this can be faster than reading mysql.
Both neglectable though, proper solution (if the elements styled are also dynamic), to cache the css or define it in the same logic which generates the blocks.
Admin
As long as we're on the subject of bizarre CSS, why the fuck do those #RGB codes have 15px top and bottom padding AND a 1px gray border, outside the padding?
http://i.imgur.com/q0n0mgP.png
See the 1px bgcolor line through the "poin" in pointer? That's the border.