Category Archives: web_dev

WordPress media “has failed to upload due to an error”

A quick checklist for myself, because this problem nearly always seems to occur on a fresh WordPress install, and it’s easy to forget what works!

1. Create the uploads folder yourself, in lowercase – “uploads” not “upLoads”

2. upload this folder to the wp-content folder

3. change the uploads folder’s permissions to 777 (and temporarily change wp-content to 777 as well just to be sure)

4. go to settings > media and add the full url to the uploads folder into the “Full URL path to files” field.

5. upload an image

6. reset permissions for wp-content to what they were to start with.

No guarantees but it seems to work for me.

note: Since I originally put this up we have started using a different isp and the problem rarely occurs now, so the solution above is probably a solution for specific situations rather than across the board. However anything is worth trying if you’re stuck so I hope it’s useful to someone!

 

WordPress widgets not working?

We recently had the apparently common problem where suddenly we could not drag, drop, open, close, or do anything else with the widgets in the WordPress admin.

The advice to fix this usually begins with turning off all your plugins and is usually followed by lots of comments about how people have done this to no effect.

Luckily for us we found a piece of advice that fixed the problem without the need to do any of this.

Just upload and activate the following plugin: Use Google Libraries

No guarantees but it worked for us.

 

Using Google Maps API keys on sites with multiple domain names

We had an error message on a client’s site that read something like:

“Error: You Google Maps API key needs updating.”

So far so simple, go and generate a new API key which should look a little something like this:

// Note: you will need to replace the sensor parameter below with either an explicit true or false value.
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAACFstjnjkgkzkvm89Q7I1ehQ8rLNggDGnTj1_01CfjEtYdR51pBR49BdeA_tqUtwCLMRE-T-IxL4uCg" type="text/javascript"></script>

Despite testing the client insisted this wasn’t working. It turned out that there were two domains a .com and .co.uk.

For each domain you need a different API key. Google provides some good documentation on how to combat this problem, however this worked sporadically and not at all on Internet Explorer, so I tried this bit of javascript (it needs to be placed in an external javascript file)

var address = (window.location.host);
// returns the page url

if (address == "yourwebsitename.com") {
document.write ("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=YourFirstGoogleMapsAPI' type='text/javascript'></script>");

} else {

document.write ("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=YourSecondGoogleMapAPI' type='text/javascript'></script>");

}

Now this all worked fine apart from on Internet Explorer again. This was because:

var address = (window.location.host);

Most browsers return the following string:

yourwebsitename.com

However Internet Explorer returns:

www.yourwebsitename.com

But adding an extra else if statement solved this (and would also work for very other additional domain name if you have more that two).

var address = (window.location.host);
// returns the page url

// condition for first domain name

if (address == "yourwebsitename.com") {
document.write ("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=YourFirstGoogleMapsAPI' type='text/javascript'></script>");

// condition for first domain in Internet Explorer

} else if (address == "www.yourwebsitename.com"){

document.write ("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=YourFirstGoogleMapAPI' type='text/javascript'></script>");

// condition for second domain name in ALL browsers

} else {

document.write ("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=YourSecondGoogleMapAPI' type='text/javascript'></script>");

}

 

Superfish menus displaying behind Cufonised text?

Building a site that used superfish drop down menus, and cufon for headings, in certain browsers (ie ie) the menus were appearing behind the cufonised headers. A z-index issue.

As usual googling produced plenty of results, most of which didn’t work. The solution that worked can be found at webdemar.com/webdesign/superfish-jquery-menu-ie-z-index-bug/ and it’s very simple. Thanks webdemar!

 

WordPress broken rss feeds

I had a broken rss that read “XML Parsing Error: XML or text declaration not at start of entity…” on a WordPress site.

There are many fixes suggested for this on the web, and I tried many, including changing themes, deactivating all plugins, adding new plugins etc etc, none worked.

The one that finally did work can be found at www.w3it.org/blog/wordpress-feed-error-output-solution-how-to/

Thank you w3it, I wish I had found you sooner.

 

Creative Commons and flickr = free photos

Our clients don’t all have large budgets, and we’re always looking for affordable ways to help them spice up their websites.

There is a way to find quality photography for your site or blog for free from flickr. It’s all to do with Creative Commons.

Thanks to skelliewag.org for this explanatory article, or go straight to flickr / Explore / Creative Commons to find out for yourself.