I'm interested in the possibility of having a skin for background image.
It may be too complex, or too much of an edge case (or both) but I'm interested to hear what others think.
I have not thought it out 100% but it could possibly be done by:
- Adding a skinr form element for managed_file.
- The file is uploaded and the fid stored as the value for the skin.
- During skinr_preprocess, the fid is used to get the path to the image and then something is done with it.
The next part is what to do with the path.
If it was decided that this file upload feature was only for the background-image property, then css for background-image could be added by doing something like:
<?php // Not actual code, just to give an idea.
$build['#attached']['drupal_add_css'] = array(
array('css for background image goes here', array('type' => 'inline')),
);
?>
I know that maybe isn't how attaching css was intended however it is the only way to use it to add non-file css.
Alternatively, css file(s) could be generated and stores in the files directory and then attached.
The field could have a 'class' property that defines the class to assign the background-image property to.
If it was ever wanted to be used for other properties, the property to use the file with could also be a field property specified via hook_skinr_skin_info()/hook_skinr_skin_PLUGIN_info().
Thoughts? Too crazy/not useful enough/fantastic idea?
I'm happy to do the work for it if it is going to be possible to get it in.
It could be hacked around in an external module, however it would be pretty dirty and some code in skinr would have to be duplicated in the external module.
Comments
Comment #1
moonray commentedThis is definitely not in the scope of Skinr. You're welcome to create an add-on module, though.
What code do you foresee needing duplication to achieve this? I don't believe you'd need to duplicate a lot.
hook_skinr_preprocess_alter()is your friend in this case.Comment #2
rooby commentedI will see how far I get with
hook_skinr_preprocess_alter()and the skin form callback and get back to you.Thanks.
Comment #3
rooby commentedI was able to do it with an add on module with the patch in #1299162-28: Unable to get theme settings in skinr ui form.
Thanks for the tips.
Due to time constraints my solution has a couple of things a little specific to the website it is for but when I get some time I will generalise it and make a sandbox out of it.
Comment #4
discipolo commented@rooby would be great if you passed along what you have. i would like to see that
Comment #5
rooby commentedYeah, I'm pretty sure it can be generalised.
I was actually planning to make a module for it, it works quite well.
I'll see what I can do in the next couple of days.