This patch makes image.module use the stylesheet_import theme function to include its CSS file (e.g image.css)

This enables theme makers to override any CSS files included and include their own instead as demonstrated here, for example.

Comments

AmrMostafa’s picture

Status: Reviewed & tested by the community » Needs review

sorry, correcting the status.

AmrMostafa’s picture

Title: Use stylesheet_import to include CSS » correcting status

sorry, correcting the status.

AmrMostafa’s picture

Title: correcting status » Use stylesheet_import to include CSS
seanr’s picture

Looks good to me. I think this is ready to be committed (but I'll let the module author make that status change, of course). I've produced a patch which does the same for 4.7 (posted in a separate issue).

Stefan Nagtegaal’s picture

Version: 4.6.x-1.x-dev » 6.x-1.x-dev
Assigned: AmrMostafa » Stefan Nagtegaal
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new765 bytes

drupal_set_html_head() shouldn't being used for inclusion of stylesheet. For that purpose drupal_add_style() was introduced.

See attached patch, and yup.. It's ready to rock and roll!

TDobes’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

no no no no no

First of all, this is a duplicate of bug 53072. (I suppose since this one is older, technically 53072 is the duplicate.)

Secondly, theme_add_style should NEVER NEVER NEVER be used for including a module-specific stylesheet. Doing so prevents properly-written themes from overriding the module CSS if they so choose. Please see my (exceptionally wordy) explanation from a core issue.

Perhaps there should be a handbook page about this or something? or maybe I should do a documentation patch?

TDobes’s picture

To clarify:

* Yes, we should use theme('stylesheet_import') -- and a patch has landed which does this.
* No, we should not use theme_add_style... and no module ever should unless it's trying to OVERRIDE the theme for some reason (i.e. CSS that was manually entered or created by the end user)

AmrMostafa’s picture

I Agree. Thanks for the clarification and my apologies for the mistake.