Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#11035 closed defect (bug) (duplicate)

gallery function put invalidate style in body

Reported by: thomask's profile thomask Owned by:
Milestone: Priority: high
Severity: minor Version: 2.8.5
Component: Validation Keywords: gallery, validation, style
Focuses: Cc:

Description

standard wordpress gallery shortcode put <style> just before the gallery, so inside the <body>. According to W3 validation service, this is invalid way, it must be in the <head> section of the document

document type does not allow element "style" here
		<style type='text/css'>
The element named above was found in a context where it is not
 allowed. This could mean that you have incorrectly nested
elements -- such as a "style" element in the "body" section
instead of inside "head" -- or two elements that overlap
(which is not allowed).

Change History (2)

#1 @hakre
15 years ago

The bug is in the function gallery_shortcode() inside the global namespace. It's located in the initial string that is send to the gallery_style filter as first paramter in ~ line 716.

Next to the invalid output, the filter name is misleading. It does not only contain the stylesheet (which could be then re-useable without any fuss in the head). Instead it contains an opening <div> element as well.

A "fix" could be to extract that style element after the filter has run and enqueing it into the head section. For this output bufferung must have been used which is not the case.

So this is not a fix (even if it would work it's pretty akward).

Default galleries html code should be more modular sothat a more generic css can be put inside the default themes head / stylesheets. That means replacing IDs with classes and general classes. This should be usefull for pretty much of all standard use-cases.

Other cases can then use filters / actions to handle the galleries output (apply css to the galleries html by using style attributes). Should make the whole complex more useable.

#2 @miqrogroove
15 years ago

  • Milestone Unassigned deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.