This feature would be very helpful for me as well. My client frequently changes out the image in the widget, but needs the title to remain the same.
Yeah, this is sort of critical – Clients shouldn’t have to mess with this … Seems really sloppy.
I think you can get the result you want easily enough:
Hard Coded Title
- Create a new folder called “image-widget” in your template directory and copy over the “views/widget-admin.php” and “views/widget.php” files from the plugin directory. If these files exist, the plugin will use these files instead of the ones in it’s own folder. More details here
- ‘widget-admin.php’ contains the admin area interface of the plugin. Open it and comment out the section that asks the user for the title. Then just add a new hidden element that contains a hard-coded title e.g.
<input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="hidden" value="Currently Reading" />
Note that this will hard-code the title for all instances of the widget.
Fixed Width Image
In your theme’s CSS add a rule that forces the width to be whatever you need for your theme.
/* .widget_sp_image is applied to all instances of the Image Widget */
.widget_sp_image img {
max-width: 300px !important; /* Overrides plugin default width, Images can still be narrower than 300px */
/* OR */
width: 300px !important; /* Forces width, narrower images will be stretched */
}
Just put 100% in the width
Hi.
Can someone with better knowledge of me hepl me out with adding option for custom width of the widget?
Thanks in advance
Great work @eoinkelly!!!
Dude! @scott Hendison, it’s not sloppy, it’s intentional. I’m open to suggestions but I work hard for free on this stuff and take offense to having my work called ‘sloppy’.
FYI, we just deployed a new version (3.3.7) with filters for width / height. That means that you can easily override them in your theme.
image_widget_image_width
image_widget_image_height
in theory you could use these filters to override whatever width or height is specified.