Theme option: Selecting an image from the media database

Discussion corner for Developers of Serendipity.
Post Reply
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Theme option: Selecting an image from the media database

Post by yellowled »

A long time ago, in a galaxy far, far away, a young Jedi knight -- I believe it was Judebert -- implemented a great feature in our little light sabre called s9y: template designers are now able to give users a theme option giving them the possibility to select an image from the media database. I think this was originally done to pave the way for the customizable header image in Bulletproof.

Now, if users actually select an image, the theme option generates a preview of said image, which is basically awesome, but displayed tiled. Which looks, well, confusing, to say the least. It would actually be very simple to fix that (by adding an [inline] style -- background-repeat: no-repeat; -- to the preview div for the image), but unfortunately, I have no idea where to even begin looking for the appropriate piece of code.

So, Jude (or anyone), where the hell is that thing in the s9y code? :mrgreen:

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Theme option: Selecting an image from the media database

Post by garvinhicking »

Hi!

./include/functions_plugins_admin.inc.php

Code: Select all

function change_preview(id)
{
    var text_box = document.getElementById('serendipity[template][' + id + ']');
    var image_box = document.getElementById(id + '_preview');
    var filename = text_box.value;
    image_box.style.backgroundImage = 'url(' + filename + ')';
}
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Theme option: Selecting an image from the media database

Post by yellowled »

garvinhicking wrote:./include/functions_plugins_admin.inc.php
Thanks. Fix committed to trunk.

YL
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Theme option: Selecting an image from the media database

Post by Don Chambers »

I didn't check your revision... Did you do did background-repeat: no-repeat for all, or only those where the background image was, in fact, set to no-repeat? Should probably set exactly the same background properties that can be set (bottom, top, center, etc).
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Theme option: Selecting an image from the media database

Post by yellowled »

Don Chambers wrote:I didn't check your revision...
You never do. :P
Don Chambers wrote:Did you do did background-repeat: no-repeat for all, or only those where the background image was, in fact, set to no-repeat? Should probably set exactly the same background properties that can be set (bottom, top, center, etc).
I can't even access the other variable holding the background-repeat from where I'm doing this (as far as I can see). Remember, this is not in BP, it's in the s9y core. Besides, it might as well be used in other templates which don't even offer a background-repeat for the image in question. So the general function for this (in the core) should not use background-repeat at all.

Besides, I don't think a "preview" of a tiled image makes sense here. The area for displaying it is rather small, it's not in the context where the image will be used ... I really don't think it is of much use. However, if it's possible at all to add that to BP, we could at least test it. But I sure as hell have no idea whatsoever how to implement that :)

YL
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Theme option: Selecting an image from the media database

Post by Don Chambers »

I check revisions.... once in a while! :P :mrgreen:

Yes, background position and repeat are handled by BP's index.tpl... thought you were making this change not just to the core, but within the context of BP. Come to think of it, not sure how that would work in the back end.

Never mind. Carry on. Nothing to see here. :mrgreen:
=Don=
Post Reply