Upload file with preset name
Hi again low :)
I'd love to be able to use the file upload form to change images in the CSS but the file would need to be uploaded with the right name. Would it be possible to force the filename for an upload field?
Replies
Low 20 Jan 2010 18:19
Hey Robin,
I'll do some research, but for now, you could use this method:
Instead of renaming an existing image (and all the caching hiccups that might cause), simple add an inline style block in the <head> of your template.
Say you've got this rule in your CSS file:
#header {background:#fff url(../images/default_header.png) no-repeat}
Then below that, use this code inside your regular template, probably in a header embed. It will override the statement in your CSS file.
<style type="text/css">
#header {background-image:url({my_select_file_variable})}
</style>
Voilà, user editable header images. :)
robin 20 Jan 2010 18:26
True, i didn't think about the cache. Was just trying to avoid adding inline styles. Anyway this should be ok for now.
Thanks.
Low 20 Jan 2010 18:32
For what it's worth, I think use like this justifies inline styles (well, a <style>-block in the <head>), because of its dynamic use. If you really want to keep it clean, you could enable early parsing and wrap the style-tag around an {if}-statement.
Oh, and if you have more feature requests, could you post them under 'Share an idea'? That way I can treat them as proper requests and mark them as 'Implemented' and whatnot... Thanks!
robin 20 Jan 2010 19:10
Sure thing