Title: Image Widget esc_attr() function misplaced
Last modified: August 20, 2016

---

# Image Widget esc_attr() function misplaced

 *  Resolved [devon](https://wordpress.org/support/users/romaspit/)
 * (@romaspit)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/image-widget-esc_attr-function-misplaced/)
 * This plugin is great, but I’ve been working on a theme that requires a widget_title()
   filter, and after updating the plugin today, I noticed that the widget title 
   wasn’t displaying as intended any more.
 * The widget_title() filter is currently applied in image-widget.php, on line 206:
 * `206: $title = apply_filters( 'widget_title', empty( $title ) ? '' : $title );`
 * Then, in views/widget.php, esc_attr() is applied to the $title output on line
   12:
 * `12: if ( !empty( $title ) ) { echo $before_title . esc_attr($title) . $after_title;}`
 * This causes certain HTML markup added in the widget_title filter to display as
   encoded tags instead of as intended (see [http://codex.wordpress.org/Function_Reference/esc_attr](http://codex.wordpress.org/Function_Reference/esc_attr)).
 * It seems to me that the esc_attr() function should be applied when saving/updating
   the widget, instead of when the output is being displayed.
 * I hope the author will take this into consideration in a future update. Until
   then, I’ve modified my local copy of the plugin as a temporary fix – otherwise
   I just won’t be able to take advantage of plugin updates without testing them
   first.
 * [http://wordpress.org/extend/plugins/image-widget/](http://wordpress.org/extend/plugins/image-widget/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Peter Chester](https://wordpress.org/support/users/peterchester/)
 * (@peterchester)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/image-widget-esc_attr-function-misplaced/#post-2633430)
 * Thanks [@romaspit](https://wordpress.org/support/users/romaspit/)! This has been
   addressed in 3.3.2.
 *  Thread Starter [devon](https://wordpress.org/support/users/romaspit/)
 * (@romaspit)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/image-widget-esc_attr-function-misplaced/#post-2633507)
 * Thanks! I updated this morning, and it works as expected!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Image Widget esc_attr() function misplaced’ is closed to new replies.

 * ![](https://ps.w.org/image-widget/assets/icon-256x256.png?rev=2489603)
 * [Image Widget](https://wordpress.org/plugins/image-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/image-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/image-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/image-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/image-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/image-widget/reviews/)

## Tags

 * [widget_title](https://wordpress.org/support/topic-tag/widget_title/)

 * 2 replies
 * 2 participants
 * Last reply from: [devon](https://wordpress.org/support/users/romaspit/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/image-widget-esc_attr-function-misplaced/#post-2633507)
 * Status: resolved