#41919 closed defect (bug) (fixed)
Image Widget Custom Link Target
Reported by: | Nenad Obradovic | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.8 |
Component: | Widgets | Keywords: | commit has-patch |
Focuses: | Cc: |
Description
Hi,
I think there is a small issue inside WP_Widget_Media_Image Class with link_target_blank option, when you render html code for this widget (code below) you only set target value to be _blank if this option is set in otherwise target value is empty and HTML validator mark this empty target value as error because that attribute can't be empty. Thanks
! empty( $instance['link_target_blank'] ) ? '_blank' : '',
Best regards,
Nenad
Attachments (3)
Change History (11)
#1
@
7 years ago
- Keywords needs-patch good-first-bug added
- Milestone changed from Awaiting Review to 4.9
- Version changed from 4.8.1 to 4.8
#2
@
7 years ago
Good catch! Thanks for the ticket.
However, looking at HTML5 coding standard the only two values allowed for target attribute are _blank
and _self
.
Values like _top
, _parent
and <frame_name>
are now deprecated in HTML5 standard.
http://html.com/attributes/a-target/
The line in question is also checking only for the value _blank
, keeping above in mind. So, how about we do not add the target
attribute at all if the value is not _blank
since _self
is default if no target attribute is set.
I have uploaded a modified diff. Please let me know if this makes sense.
#3
follow-up:
↓ 7
@
7 years ago
- Keywords commit added; good-first-bug removed
- Owner set to westonruter
- Status changed from new to accepted
@subrataemfluence Your patch is perfect. Exactly what I was envisioning.
#4
@
7 years ago
It looks like actually 41919.2.diff doesn't go far enough. There are other attributes, including class
and rel
that also should be omitted when empty. See 41919.3.diff.
#7
in reply to:
↑ 3
@
7 years ago
@westonruter Thank you! Also thank you for considering class
and rel
attributes as well :)
Replying to westonruter:
@subrataemfluence Your patch is perfect. Exactly what I was envisioning.
You're right. Would you like to submit a patch?
For reference, here's a direct link to the code in question:
https://github.com/WordPress/wordpress-develop/blob/88464ec/src/wp-includes/widgets/class-wp-widget-media-image.php#L244-L248