r/csshelp • u/kjhatch • Nov 15 '11
Default Thumbnail Image Replacement
It appears Reddit updated the old default thumbnails from /static/noimage.png (etc.) to a new combined sprite:
/static/sprite-main.oJ5XDExA73c.png
That broke the custom thumbnails I had set up for my subreddit. I've tried to simply update the CSS reference to fix it, but nothing works. I've tried path, filename, type, or even class to get at it, but all are ignored. Begins-with and ends-with selectors fail. It's like Reddit's also now generating it in a way that gets around the default CSS DOM.
Am I missing something? Does anyone know a new trick to customize the default thumbnails?
1
u/astroot Nov 15 '11
You can customize these:
.thumbnail.selfand
.thumbnail.defaultDefault is the alien with the question mark, self is the alien with the exclamation point.
1
u/kjhatch Nov 16 '11
Yep, I did try both of those, directly to set the background image to either double class container and attempting to define the image inside the container defined by the double class, and none of it took. That's why I posted here asking. Is there a working example on a subreddit?
2
u/astroot Nov 16 '11
.thumbnail.default{background-image: url(%%thumbnail-default%%) !important}I uploaded an image, named it thumbnail-default, then used the code above and it worked perfectly.
3
u/kjhatch Nov 16 '11 edited Nov 16 '11
The issue that failed with the double classes is the new sprite now applies this to the container:
background-position:0px -298px;to move the sprite into position. When that is combined with the:
background-repeat:no-repeat;common in the older background management code (like TedFromTheFuture's example below), a smaller image disappears from the container entirely. Removing the no-repeat helps, but depending on the size of your custom thumbnail that may not position properly (as mine didn't).
The solution is to override the sprite's position (that you don't need anyhow) like this:
.thumbnail.default, .thumbnail.self {background-image:url(%%thumbnail%%) !important;background-position:top left;}That works fine for me. If you want different thumbnails for default and self, just split out the definitions. You can see it in action on my subreddit. There are still some minor cross-browser issues with it that will need to be worked out. In my case I use a border radius, and it's not applying consistently across different browsers anymore, but the replacement itself is good.
1
2
u/[deleted] Nov 15 '11
My code is no longer working as well:
I'm still waiting 10 min. for the default stylesheet to load (link to the bottom right of your stylesheet). Search for .thumbnail, and see what they are using, so we can fix it.