Make WordPress Core

Opened 8 years ago

Closed 3 years ago

Last modified 3 years ago

#36640 closed enhancement (fixed)

Customize: get_custom_logo should allow the image tag to be filtered independently

Reported by: achbed's profile achbed Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version: 4.5
Component: Customize Keywords: has-patch has-dev-note
Focuses: Cc:

Description

To allow for further customization of the image tag used in the custom logo, I propose adding a get_custom_logo_img filter to get_custom_logo. This will allow for cleaner modification of the a tag content.

This would be useful in optionally adding accessibility on the image and other content within the home link.

Attachments (3)

custom-logo-img_filter.patch (1.0 KB) - added by achbed 8 years ago.
custom-logo-imgattr_filter.patch (1.1 KB) - added by achbed 8 years ago.
Alternate: Filter for the attributes only instead of the entire img tag
36640.diff (936 bytes) - added by dlh 4 years ago.

Download all attachments as: .zip

Change History (20)

#1 @westonruter
8 years ago

  • Keywords has-patch added
  • Version changed from trunk to 4.5

Giving more control over the generation of the img markup makes sense, but we'd want to make sure that custom-logo-link class is always includes as otherwise the selective refresh selector will fail to match. Well, I suppose we could still allow it to be changed, but the plugin that filters get_custom_logo_img should also make sure it updates $wp_customize->selective_refresh->get_partial( 'custom_logo' )->selector as required. This should be noted in the filter description.

#2 @achbed
8 years ago

I supposed for accessibility and theming purposes, we could simply allow filtering the image tag attributes. We can then enforce the custom-logo-link class after the filter returns.

@achbed
8 years ago

Alternate: Filter for the attributes only instead of the entire img tag

@dlh
4 years ago

#3 @dlh
4 years ago

  • Milestone set to 5.4

[45028] removed itemprop from the default custom logo attributes. The get_custom_logo and wp_get_attachment_image_attributes filters were suggested as options for restoring itemprop, and while those certainly work, the filter suggested here would arguably make the process a little less cumbersome.

36640.diff refreshes the previous patch with a couple changes:

  • Rename the filter to get_custom_logo_image_attributes for consistency with wp_get_attachment_image_attributes.
  • Move the attachment ID to the second filter parameter under the assumption that it'll be more common to need that ID than the current blog ID.

As highlighted in comment:2, the custom-logo-link class should still be unaffected by the filter.

I'll check in with #core-themes for other opinions, and maybe there can be a yea or nay on this enhancement during the 5.4 cycle.

This ticket was mentioned in Slack in #core-themes by dlh. View the logs.


4 years ago

#5 @dlh
4 years ago

  • Keywords dev-feedback added

#6 @joyously
4 years ago

The description says

This will allow for cleaner modification of the a tag content.
...other content within the home link

So why is the filter on the image attributes?

#7 @dlh
4 years ago

Filtering the image attributes was suggested by the reporter in comment:2 as a simpler approach to apply the modifications they were looking for.

The title, description, and comment:1 also referenced the image tag specifically, so I took it to be the focus of the request, but perhaps that was mistaken.

For the itemprop example, at least, being able to modify the attributes array seems to me like it would be simpler than modifying the HTML content within the <a>.

#8 @davidbaumwald
4 years ago

@dlh Do you feel this is still a good candidate for 5.4 with Beta 1 in the next few days?

#9 @dlh
4 years ago

@davidbaumwald Yep, I do still think that it would be good to make a decision on this for 5.4.

#10 @davidbaumwald
4 years ago

  • Milestone changed from 5.4 to Future Release

This ticket still needs feedback and a review, and with 5.4 Beta 1 landing in a few hours, this is being moved to Future Release. If any maintainer or committer feels this can be included in 5.4 or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.

#11 @dlh
4 years ago

  • Milestone changed from Future Release to 5.5

Let's give this one more try for 5.5.

#12 @SergeyBiryukov
3 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 48057:

Customize: Introduce get_custom_logo_image_attributes filter for the list of custom logo image attributes.

Props achbed, dlh, westonruter.
Fixes #36640.

#13 @sabernhardt
3 years ago

I included some information and possible examples of the new filter in this draft dev note. If you have a better example or other input, please let me know.

#14 @afercia
3 years ago

In 48283:

Accessibility: Themes: Use a default empty alt attribute for the non-linked custom logo on the home page.

After [48039] it became clear that the non-linked custom logo on the home page needs an empty alt attribute, as in most of the cases the logo is decorative and doesn't need its purpose to be described.

This change outputs an empty alt attribute by default for the custom logo on the home page. If necessary, it is possible to use the new 'get_custom_logo_image_attributes' filter to manipulate the default attributes for the logo image and set an alt attribute.

Props FlorianBrinkmann, Soean, sabernhardt, audrasjb, SergeyBiryukov, samful, knutsp.
See #36640.
Fixes #37011.

#17 in reply to: ↑ 16 @SergeyBiryukov
3 years ago

  • Keywords dev-feedback removed

Replying to johnstonphilip:

should this be punted from 5.5 due to the concerns raised here?

This ticket is just about the get_custom_logo_image_attributes filter added in [48057].

I think the concerns are related to #37011. Reopening that one to see if that's something to address for 5.5 RC2.

Note: See TracTickets for help on using tickets.