Using Images With SBPM

One of the many questions I get asked about using SBPM with WordPress is how it can be used to create random images within the content of your posts and pages.

You might want to do this to add some visual disruption to your posts, to help separate one area from another, or to highlight a product or type of product you are talking about in the post content. Adding images to posts is always a great idea and is something that many readers want from a good website.

​Adding random images.

photo credit: Gangsta Cat (license)

To add these random images within our SBPM posts, we will have to rely on a little combination of HTML and SpinTax. WordPress is great at allowing you to add images using their interface, selecting the size, title, alt text and positioning but we will have to go a little “old school” here to get the result we need.

I will have to assume something here too, that you either have a folder full of images called pic1, pic2, pic3 etc, or a folder with images called names such as product.jpg, main-pic.jpg, logo.jpg etc.

Which ever of these you have, it is best to start by getting a list of the file names you want to have shown in your content. If you are using an image as part of a post about a product or line of products, make sure it is relevant and not too specific to a model.

This will avoid your post about the WhizzBang Juicer 200 having an image showing the CrappyJuiceSystem 100 instead. In these circumstances, a generic picture of someone juicing might be more relevant - but there are ways we can add the specific image if we want to, but more of that later.

Adding a basic image.​

The basic HTML command to add an image to a web page is as follows:

<img src=“filename.jpg”>

This will load and display an image called filename.jpg (probably from the root folder of your domain) and display it in the WordPress page or post, without adding any additional settings that might tell your browser how big it should be or what the ALT text is.

If we had a list of images that we wanted to show randomly within the post, we could use some Spintax to select one and show it.

<img src=“{image1|image2|image3|image4}.jpg”>

Each time SBPM makes a post or page with this code, it will randomly select either image1, 2, 3 or 4 and add that in to the page content. Of course, you will need to have images already uploaded that match those names or the HTML will just show an empty space.

We could make that little block of Spintax even simpler, like this, where we are only spinning the number, rather than the entire filename:

<img src=“image{1|2|3|4}.jpg”>

But what if you have a selection of images that all have different names?

Unfortunately, the Spintax will get a little complicated here, but only have to make it once.

<img src=“{product|main-pic|logo}.jpg”>

Here, we are referencing individual images with differing names, which we have made a list of earlier. Although they are all JPG files in this example, they could just as easily be a mixture of image formats too. You will just need to tweak the Spintax in SBPM to account for this.

<img src=“{product.gif|main-pic.png|logo.jpg}”>

Adding specific images.​

photo credit: Juice FTW!

There are a few ways that SBPM could be used to add specific images to a post or page. You might want to do this to show an exact product when posting an Amazon review.

You can upload an image that matches the keyword you are using to create the post and use  HTML to load the exact image.

SBPM will replace the %%keyword%% placeholder with the name of the post and the relevant image will be loaded. For example, you could have the following keywords loaded in SBPM to create posts.

Juicer 9000
Fruit Crusher Pro
Banana Musher​

If you wanted to load an image for each of these, you would could add the following code in to your content:

<img src=“%%keyword%%.jpg”>

However, you would need to ensure you have images with the exact names (including capitalisation and spaces) uploaded too:

Juicer 9000.jpg
Fruit Crusher Pro.jpg
Banana Musher.jpg​

The same type of functionality could be achieved using SBPM custom variables with your keywords. If you add an %%image%% variable to each keyword, you can control which image will be shown:

Juicer 9000(image=juicer-900.jpg)
Fruit Crusher Pro(image=fruitcrusher.jpg)
Banana Musher(image=Banana-Musher.gif)​

You could then add the following code to the SBPM content, referencing that new image variable.

<img src=“%%image%%”>

Grabbing images from Amazon.

photo credit: Amazon boxes

Loading images from items from Amazon is easy when use can use the ASIN number of the product as a custom variable. Amazon have a great naming convention for their images, so by adding the ASIN as a customer variable to your keywords you can add the images quite easily.

See my post on using AmaSuite to get keywords and products for SBPM here, where you can learn how to quickly and easily get the ASIN number for each product.  You can also use the CSV To SBPM converter to take data from AmaSuite and make it compatible with SBPM.

Lets add the ASIN custom variable to our keywords for each of the products we are making posts about:

Juicer 9000(ASIN=B123456)
Fruit Crusher Pro(ASIN=C678900)
Banana Musher(ASIN=A112233)​

The link to a medium size Amazon product uses the ASIN code as part of the URL, so using the new ASIN custom variable, we could grab the image for each of the 3 products we have listed as follows:

<img src=“http://z-ecx.images-amazon.com/images/P/%%ASIN%%._SCRMZZZZZZ_.jpg”>

This will allow you to show the specific image for the specific Amazon product in your content.

Formatting your images.

Once you have chosen which images you will show in your content, you can add some additional HTML code to your <img> tag that will style the image and also add other useful SEO data.

Align the image randomly

When you show your image, you may want to have the text flow around it, rather than it just leaving it hanging there on it’s own. To do this, you will need to add the ALIGN element to your image.

<img src=“image1.jpg” align=“left”>

The above example will move the image to the left hand side of the screen and any text following that image will be wrapped around the side. The full list of options are:

  • left - Align the image to the left
  • right - Align the image to the right
  • middle - Align the image in the middle
  • top - Align the image at the top
  • bottom - Align the image at the bottom​

​Using Spintax, we can randomise the output of the ALIGN attribute, like this, allowing for a truly random output of how the image appears on the page:

<img src=“image1.jpg” align=“{left|right|middle|top|bottom}”>

ALT text and TITLE text

photo credit: Life Story

If you want to follow the proper HTML standards, each image should have a title and also some “ALT text”. The title should give a description of the image and the ALT text is shown if the browser has the images turned off or if the image can’t be shown for some reason.

The ALT text is generally used to tell visitors what the image is and should be short and sweet, whereas the TITLE attribute can be more descriptive and tell the visitor what the image is about and include supporting information.

These 2 attributes are mainly used to improve website accessibility, where people with impaired vision or mobility are wanting to use your site. However, these 2 attributes are also good for improving the SEO of the page.

<img src=“image1.jpg” title=“The juice crusher 900 is excellent for creating carrot juice” alt=“juice crusher 9000”>

Using Spintax, you can change these 2 values to become more unique for each image on your page.

<img src=“image1.jpg” title=“{This|The} juice crusher 900 is {amazing|cool|perfect|excellent} for {making|creating} carrot juice” alt=“{The juice|juice} crusher {9000|nine thousand}”>

Putting it all together.

Now we know how to add random images, or specific product pictures using Spintax and SBPM, we could put all of these elements together to create the full IMG tag.

<img src=“image1.jpg” align=“{left|right|middle|top|bottom}” title=“{This|The} juice crusher 9000 is {amazing|cool|perfect|excellent} for {making|creating} carrot juice” alt=“{The juice|juice} crusher {9000|nine thousand}”>

You can also reference any other SBPM variables or custom variables in these 2 elements too, which will make them more relevant, especially if you are using random images.

<img src=“image1.jpg” align=“{left|right|middle|top|bottom}” title=“{This|The} %%keyword%% is {amazing|cool|perfect|excellent} for {making|creating} juice” alt=“%%category%% %%keyword%% %%ASIN%%”>

You could even take it further by adding image sizes or some CSS style too, both with some added Spintax to make them appear more randomised per page.

<img src=“image1.jpg” width=“{250|210|245|200}” style=“border:{1|2|3}px {dotted|solid|dashed} {grey|green|blue|black};” align=“{left|right|middle|top|bottom}” title=“{This|The} juice crusher 9000 is {amazing|cool|perfect|excellent} for {making|creating} carrot juice” alt=“{The juice|juice} crusher {9000|nine thousand}”>

We all know that search engines like Google and BING look for footprints on pages to try to determine if they are spam or auto-generated garbage. Using these techniques to show images in your SBPM content, you can make the pictures on your pages appear more unique. Taking the time to do this will make your site look better and get more visitors in the long run.

Use your theme's image styles.​

Depending on which WordPress theme you are using, you may also have some additional image styles or attributes you can use. Often, themes use CSS to ALIGN the images left or right or have built-in support for adding drop shadows or fancy boxes and borders.

If you want to use these in your SBPM code, it would be best to create a dummy post in WordPress, add an image and start messing with the options. You can then look at the HTML code that produces the image and copy that as a starting point.

For example, using Thrive Themes (which I use on this site) when adding an image to a post, it automatically adds an HTML CLASS element to the IMG tag:

<img class=“alignleft wp-image-280 size-medium” src=“http://www.wp-sbpm.com/wp-content/uploads/2015/03/csv-to-sbpm-tool-output-300x180.png” alt=“csv to sbpm tool output” width=“300” height=“180” />

The theme uses the CSS class to align the image and also set the size, all of which will be used to determine how much of a margin to show around the image and how it will look on the page. If you start to experiment with making your images look different, you can look at how the images are handled in your theme for some more formatting and styling hints.​

Click Here to Leave a Comment Below 0 comments

Leave a Reply: