WordPress relative url’s in posts

If have you ever used wordpress in an environment where you have dev, testing, staging and production environments you would understand that the default wordpress uses when inserting media into posts is by adding the complete url to the media item. Now In a scenario where you have different environments with different urls and you use git and scripts to snc the database between the environments the full url can cause issues because as soon as its deployed to a new environment the urls will differ and your images in your content will be broken.

So the easiest way to fight this is by changing the way wordpress inserts the media items, instead of adding in the full url’s rather add them with a relative url. What this means is instead of adding a url like “http://www.domain.co.za/wp-content/uploads/07/image.jpg” it will insert a url like “/wp-content/uploads/07/images.jpg”.

Basicly it doesnt matter what the domain is the images will include correctly and when deployed over to new environment it will work fine.

So this can be accomplished with a few lines of code that you can add into the functions.php of your theme.

function switch_to_relative_url($html, $id, $caption, $title, $align, $url, $size, $alt)
$imageurl = wp_get_attachment_image_src($id, $size);
$relativeurl = wp_make_link_relative($imageurl[0]);
$html = str_replace($imageurl[0],$relativeurl,$html);

return $html;

How To: Leverage browser caching

If you are using google pagespeed to measure your site speed you might find it says you must leverage browser caching to improve your site speed.

Fairly simple job and fairly standard. All you need is to add a few lines of code to the .htaccess file which can be found in the root of your website files.

Open it by using filemanager in your cpanel or downloading – editing – and uploading it.

When opened go to the last line and on a new line add the following:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"


Windows 10 Cant send email Issue

I recently found a few client phoning me explaining, they cant send emails from outlook even though on the account settings screen the “Test Account Settings” test delivers successful results.

The Message Office gives is something similar to cant connect to server. All of the clients had one thing in common, they recently upgraded to Windows 10. Well luckily there has been oen fix that proved successful every time so far.

On the PC open a Command Prompt window, this can be done by clicking on the search icon and type “CMD”. From the results you are given right click the “Command Prompt” item and click on “Run as Administrator”.

A new window opens ( with a black background ). in this window type “sfc /scannow”.

Leave it to finish and thats it. Close your Outlook and open it again.

Should be working.

Usefull Links

Here are some links that is dropping of my bookmark bar =)

Have to save them somewhere so might as well do it here.

Awesome CSS3 E-Commerce Cart Ideas


View Link

doCapture- Free, quick, high-res, website screen captures in the exact size you need.


View Link

Designbeep – Free Resources For Designers and Developers

Screen Shot 2015-08-28 at 8.11.17 AM

View Link

WordPress SEO – The Definitive Guide To Higher Rankings For WordPress Sites

Screen Shot 2015-08-28 at 8.11.25 AM

View Link

Embed Latest Video from Channel

My Previous post about doing this was using a previous api and using callback to get the info.

Thanks to Shix_ for pointing it out there is a easier way to do this.

Simply drop this html into the place where you want the video and change the username with your username and its done.

<iframe width="300" height="200" src="http://www.youtube.com/embed?max-results=1&controls=0&showinfo=0&rel=0&listType=user_uploads&list=YOUR_USERNAME_HERE" frameborder="0" allowfullscreen="allowfullscreen"></iframe>