WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#6681 closed enhancement (wontfix)

Style lost in feed

Reported by: andrewjorgensen Owned by:
Milestone: Priority: low
Severity: trivial Version: 2.5
Component: General Keywords: style, align, images, feed, caption
Focuses: Cc:

Description

Beginning with 2.5 if I insert an image and change it's alignment to "right" using TinyMCE it adds a "float: right;" setting to a style attribute and "alignright" to the class attribute. This has the effect of changing the alignment of the image in wordpress but the rss feed generator strips out the class and style attributes so that the image is default justified instead.

Wherever possible standard html should be used within the post content so that formatting remains when the feed is viewed in a feed reader or aggregator. A feed reader will not have access to the style information. Even if the style and class attributes were not stripped the reader wouldn't have the stylesheet and the reader software may not know how to interpret the style attribute.

This can be worked around by manually adding the align="right" attribute to the img element.

If formatting specific to the align="right" case is desired by the theme author she should use, for example, img[align="right"] as the selector in the stylesheet rather than an alignright class. Using a selector in this way as opposed to a class will also cause the stylesheet propertied to be applied to posts written before the alignright class was used. See http://www.w3.org/TR/CSS21/selector.html

Change History (10)

comment:1 follow-up: azaozz6 years ago

  • Component changed from TinyMCE to General
  • Priority changed from normal to low
  • Severity changed from major to trivial
  • Type changed from defect to enhancement

Unfortunately align="right" on an image is invalid XHTML. Also the css selector img[attribute] works in most, but not all browsers. The simplest way of dealing with image alignment in rss readers is to make sure each image is in separate paragraph/block element. Then it will be displayed above/below the text and will look a lot better.

I'm not sure if WordPress should filter the rss and wrap all <img> tags in <div>, although it can be done.

comment:2 in reply to: ↑ 1 craigbox6 years ago

Replying to azaozz:

Unfortunately align="right" on an image is invalid XHTML.

It worked, though. It's not always practical in the layout to have each picture in a separate paragraph. Is there any way to patch around this behaviour (to use the old, but invalid XHTML) until the greater problem is fixed?

comment:3 Otto426 years ago

"It worked" is not the same as "it's valid".

The style of float:right is the correct thing to do, and a feedreader worth its salt should handle that one correctly. Google Reader does.

If you have something custom on the alignright class, then you're going to get different results.

comment:4 follow-up: craigbox6 years ago

As of 2.6 the float:right is now being lost from the feed entirely, replaced with

Otto's argument on the support forum is that you shouldn't put style in feeds. Specifically in the case of floating an image to beside a paragraph, it's very useful to do this, and presumably adding the style "float:right", which was the "correct thing to do" in May, is still acceptable?

Is this something that could be resolved with a plugin, if the position of the core developers is now "feeds should not have styles"?

comment:5 craigbox6 years ago

sorry -- should have read "replaced with class 'alignright' only, which would require this class to exist in the CSS of any given feed reader."

comment:6 Otto426 years ago

While I still think that is a very bad idea to include styles in feeds, I admit that it does work in the current situation... The ideal of "feeds should be text + minimal HTML only" is not something the world is ready to cope with.

What it looks like to me is that we need a feed-only filter to recognize the alignleft/alignright classes and add the style = floats in there in that case.

This is complicated due to captioning, I think, which now gets the styling for alignleft/right.

comment:7 db06 years ago

  • Keywords style align images feed caption added

I have to agree with the main point. Some way to allow the image to align in a feed in the same way it does on the normal page should be implemented.

I like to put the occasional image at the top of my posts aligned to the right in order to make it look better. I also use the caption to provide attribution. In the feed this combination just looks ugly. Text where it should not be, breaking the context, image between sentences and whatnot.

At the least we should have an option to remove captions from feeds (and possibly images). At the best, we should have a filter that puts a basic alignment on the image just for the feed.

comment:8 in reply to: ↑ 4 scribu6 years ago

Replying to craigbox:

Is this something that could be resolved with a plugin, if the position of the core developers is now "feeds should not have styles"?

There is a plugin that adds images at the beginning of posts, which are correctly alligned in feeds: Custom Field Images

comment:9 matt6 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Intelligent feed readers (like bloglines) whitelist certain style attributes.

comment:10 jacobsantos6 years ago

  • Milestone 2.7 deleted
Note: See TracTickets for help on using tickets.