How to Setting WordPress Background Image to Img

In a recent custom WordPress development project, you needed a small thing to change your WordPress theme, if your theme have all image shows CSS property like background-image: (‘url:’). first you know small things about Background images that is great to use because of how easy it is to display it properly in any constrained proportions. But there is no alt tag for screen readers, no title tags, or confirmation they are crawled and indexed.

How to Setting WordPress Background Image to Img

I have a further question on the same lines. I figured out how to change the WordPress background image to img and able to figure out where to change reference code provide and tried putting it in to website site very easy way. In this tutorial i can show live how to change all WordPress background-image to img format, build SEO image rule maker therefore include Image tags inside content paragraphs, and background images being used in blocks, or parts of content where the image is not within the text.

Step-1 Check Site have background-image or Not

In this step you want to know that your WordPress have background-image or not. Now you got same background-image to all website images then follow this all steps i can solve this problem very easy way.

There are two method to find your image property:

  • First inspect your live website and
  • Second view page source.

First Inspect Live Website:

If you can using chrome, Mozilla or any browser, now want to open your website, Well, hover over image right click on your mouse now you see option on the bottom “inspect” click on it, or simply use keyboard “Ctrl+Shift+i”. It shown the site HTML tags, code HTML format, now check there image is background image or <img format, for preference check bellow image:

Hover over image right click inspect

Second view page source code:

If not comfortable to first step inspect, so not problem at all use this to check your WordPress image property has img or background-image. Open site right click mouse show options find view source code click on it, its open new tab it contain all HTML code now find (Ctrl+f) find “background-image”.

Are you find background-image if yes go for second step, it will change your whole website Image SEO include alt tag as well as title tags, if your website not having title tags at last you can check the article How to Add Title Tag for all WordPress Images SEO Optimize.

WordPress add title to image all attributes mainly use for mouse hover

Step-2 Find background-image and Replace Code Reference

Are you complete the first step, if you find that your website have background image so that site performing low SEO properly.

Before go to this user understand some instruction to easy this steps, if you are a developer or you know about php programming or how to change code and replace you can follow this with your dashboard while theme editing through login to your WordPress Dashboard Appearance → Theme Editor →

Or you don’t know how to change or replace code from theme file, don’t worry – we can solve this into a easy without your website harm or critical error, so start, login your cPanel online hosting, go to file manager find www_public folder open it find your domain name same as your website folder name (if you not find folder name same as your website no mater), Open folder name wp-content → themes, well find your theme which one is activate, simply one click on it, select this folder and download theme file to your desktop.

It will save your theme to your desktop and edit upload activate, no error secure whole website, without any problem.

Now, open theme folder to your text editor the best text editor i prefer Download Visual Studio Code – Mac, Linux, Windows. Open theme folder, find (Ctrl+f) background-image and replace this code to:

<?php the_post_thumbnail(); ?>

This small change make SEO big move up to your website.

Or you can find this type of code to your php extension (.php) folder:

<a href="<?php the_permalink(); ?>" class="post-img" style="background-image: url('<?php echo esc_url(get_the_post_thumbnail_url(get_the_ID(),'full')); ?>');"></a>

Replace Code Reference with

<a href="<?php the_permalink(); ?>" class="post-img">
<?php the_post_thumbnail(); ?>

You can replace all over the file extension php (.php) repeat this all and replace code reference with above mention. SEO standards include in your website’s content that is the keywords in alt attribute of the image. Doing this can help to better define the main keyword of a web page, also used by screen readers to provide a description of the image to a visually impaired user.

Now your theme is re-optimize ready to install and activate it to you website, remember main theme backup store to your system, if any problem you can replace this to original one, is you follow all steps above mention carefully no chance to error. Install theme and activate and check theme image will change background image to img include alt tag. but there is not title tag this is very simply, Active all image title tag only one step.

Leave a Reply

Your email address will not be published. Required fields are marked *