Adding an image in WordPress or even a gallery is easy. However, adding images outside your posts is not that simple for beginners. Recently one of our users asked us how they can add an image in their WordPress sidebar. By default, WordPress doesn’t have an image widget. In order to add an image a user needs to manually add the HTML code. In this article, we will show you how to add an image in WordPress sidebar widget.
Manually Adding an Image in WordPress Sidebar Widget
First you need to upload the image to your WordPress site. Simply go to Media » Add New and upload your image file. After uploading the image you need to click on the Edit link next to the image.
WordPress will now take you to Edit Media page, where you will see the image file URL on the right side of the screen. You need to copy this URL and paste it in a text editor like Notepad.
Now you need to go to Appearance » Widgets screen and drag-drop a text widget to your sidebar where you want to display the image.
In the text box area of the widget, you need to add your image using this code:
<img src="Paste The File URL Here" alt="Strawberries" />
The
img
tag is used in HTML to display images. It needs two attributes, the first one is src
which defines the image file location. This is where you will paste the URL you copied earlier.
The second one is
alt
which is used to provide an alternate text for the image. Your final img tag will look something like this:<img src="http://www.example.com/wp-content/uploads/2014/09/strawberries.jpg" alt="Strawberries" />
You need to click on the Save button to save your widget and then preview your website.
Adding an Image in WordPress Sidebar Using Image Widget
An easier way to add images to your WordPress sidebar is by using a plugin. First you need to install and activate the Image Widget plugin.
Upon activation, simply go to Appearance » Widgets. There you will notice a new Image Widget in your available widgets. Simply drag and drop this image widget to your WordPress sidebar where you want to display an image.
The good thing about the image widget is that you don’t need to write any HTML at all. Simply use the media uploader to upload your image right from the widget.
As soon as you upload an image, the image widget will expand to show a preview of your image. It will also show you a number of settings that you can configure from the widget. You can choose a title, alt text, and a caption for the image. You can also choose an image size from the list of available options.
Once you are satisfied, simply click on the Save button to save the image widget. That’s all, you can now go to your website and see the image displayed in your sidebar.