Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#19878 closed enhancement (invalid)

Allow for a Custom Screen Icon

Reported by: wpsmith's profile wpsmith Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch close
Focuses: Cc:

Description

It would be nice to be able to use screen_icon for custom icons. This could easily be done either through filters and/or allowing a custom icon to be passed.

Attachments (1)

screen_icon.patch (1.3 KB) - added by wpsmith 12 years ago.

Download all attachments as: .zip

Change History (8)

#1 @TobiasBg
12 years ago

  • Keywords close added

I don't think that this filter is actually necessary.
When you pass a string to screen_icon(), like

screen_icon( 'my-plugin' );

the resulting <div> will have the ID #icon-my-plugin. You'll just need to add something like

#icon-my-plugin {
	background: transparent url( 'plugin-icon.png' ) no-repeat;
}

to the CSS file that your (or most) plugins load on their admin screens anyway. I don't see the need for adding a filter to add extra inline CSS styling.

Suggesting wont-fix.

#2 follow-up: @nathanrice
12 years ago

I think someone should try to defend the use of an empty div with CSS to display an image vs. using an actual image in the source. As far as I can tell, the way it's being done is wrong.

Seems to me, you should be able to pass an image URI to screen_icon() and have that output inside the div.

<div class="icon32"><img src="/path/to/image.png" alt="" /></div>

#3 in reply to: ↑ 2 ; follow-up: @nacin
12 years ago

Replying to nathanrice:

I think someone should try to defend the use of an empty div with CSS to display an image vs. using an actual image in the source. As far as I can tell, the way it's being done is wrong.

These images are presentational/decorative by nature, and do not hold semantic value.

#4 in reply to: ↑ 3 @nathanrice
12 years ago

Replying to nacin:

These images are presentational/decorative by nature, and do not hold semantic value.

Shouldn't they then be the background image of the H2?

#5 @nacin
12 years ago

They could, but that's not how it was architected back in 2.7. No use changing it now. If I had to guess, there were some efforts required to ensure that markup was easily compatible with plugin pages created for 2.6 and earlier, but I don't have any particular insight.

#6 follow-up: @TobiasBg
12 years ago

Nathan, don't forget that only the approach of a <div> with a background image gives you the possibility to use a CSS sprite for the image, which is a great benefit, and which is something core and some plugins do.

#7 in reply to: ↑ 6 @nacin
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Replying to TobiasBg:

Nathan, don't forget that only the approach of a <div> with a background image gives you the possibility to use a CSS sprite for the image, which is a great benefit, and which is something core and some plugins do.

That's the reason I was looking for. Thanks.

Note: See TracTickets for help on using tickets.