All posts by 2020Media Blogger

2020Media is a leading UK web host offering Linux and Windows website hosting. The company specialises in WordPress, Joomla and Drupal support.

WordPress › My Eyes Are Up Here « WordPress Plugins

Source: WordPress › My Eyes Are Up Here « WordPress Plugins

When WordPress automatically generates thumbnails, it sometimes doesn’t crop them in a way that is suitable for the image you’ve uploaded. If your image isn’t the correct format, and let’s face it, you never know what images people are uploading – you’ll run the risk of a badly cropped image. Not good. If you have a full portrait image of a person that you’ve uploaded, but you need the image to appear landscape, you’re in trouble! WordPress will centre the image so that you end up with person’s crotch. Not good. Or let’s say you have a landscape image, with a person’s face on the right hand side, but you need it to display in a square thumbnail. You’ll end up with half a face as WordPress centres the image.

What does the plugin do?

You can control how you want your WordPress thumbnails to appear on your website. Regardless of the image format you upload, you can either use the automatic face detector or if you want even more control, you can manually add hotspots.

 

PHP File Directory Script with folder sizes

A new resource for customers – the Website File Explorer. Here’s how it came about.

What it does

The item lists the files and folders in a customers webspace, giving information such as file size, modification time, folder structure and size, all in a responsive, attractive layout.

Based on the script created by Hal Gatewood at http://halgatewood.com/free/file-directory-list/ we made a modification to show the folder sizes and give a total for the space used entirely.

screenshot of Free PHP File Directory Script showing Folder content size
Free PHP File Directory Script showing Folder content size

The single-file script can be placed in a web directory and loaded in a browser. It uses scandir to locate all the contents recursively, then filesize to get the properties of each item.

Responsive, Dynamic, Modern

The script also displays a nice icon for each type of file, and the last modified timestamp.

Folders are shown initially closed but a simple click expands them dynamically to reveal the contents.

Putting the Customer in Control

The script is used as a report for our web hosting customers, to give them more information about their accounts.

Most hosting control panels show disk quota and usage, but we were asked by customers to break down the usage in detail, so that they could get an idea where the space was being used. From personal experience we know webspace gets used over time for all sorts of random things – obsolete projects, testing space, a handy spot to dump that file you need to transfer one time only….

We had been providing this information manually, using the linux du‘ command. This has useful parameters such as –human-readable and –max-depth which made it ideal. However translating this function into a customer-facing tool in a safe and secure way meant a different approach – in our case using PHP.

We continue to use ‘du’ “under the hood” to provide a daily report to customers via our customer portal. Automatic warnings are generated in case a customers is getting close to their quota.

How big is that Folder in the Window?

One interesting thing we found is the different ways that file and folder sizes are calculated. There is also some differences in parameters for du (apparent sizes, rather than disk usage) that had to be taken into account when comparing PHP’s method of calculating file space usage with Linux’s (and our FTP server software).

We display the results in human-friendly units based on one Kilobyte being 1024 bytes.

Download Script

Download the script here: file-directory-size.php.txt

Remove the .txt extension and upload to your webserver.

Caution: This script will display the names (at least) of all files in your site. Therefore caution should be used before putting it in a public location. Our use of this script is tightly locked down so that it is safe and secure to use.

We would not recommend this script is used at all where register_globals is active (e.g. older php versions).


With thanks to the original creator, Hal Gatewood and user khanvani on fiverr.com

Passing data from PHP to JavaScript · A Beautiful Site

Source: Passing data from PHP to JavaScript · A Beautiful Site

 

Ever needed to send a PHP variable, array, or object to JavaScript? It can get complicated trying to escape the output properly. Here’s a way that always works—no escaping necessary.

Passing data from PHP to JavaScript

Have you ever needed to send a PHP variable, array, or object to JavaScript? It can get complicated trying to escape the output properly. Here’s a way that always works—no escaping necessary.

Let’s say we have the following variable in PHP:

  • $name = ‘Bob Marley’;

And we want to pass it to a JavaScript variable called name. Here’s the trick:

  • echo ‘<script>’;
  • echo ‘var name = ‘ . json_encode($name) . ‘;’;
  • echo ‘</script>’;

Using json_encode(), you’ll always get a properly formatted JavaScript object.

So Your Client Wants a WordPress Slider? Here’s What You Need to Know

Whether you love them or hate them, sliders are still a popular feature of many free and premium themes. It’s not too difficult to see why: they’re eye-catching and draw attention to key information on your site. Despite the pros, there are many cons to using sliders. Here’s our verdict on whether you should use sliders or not.

Source: So Your Client Wants a WordPress Slider? Before You Cringe, Here’s What You Need to Know

Old-skool slider - not responsive, not accessible...
Old-skool slider – not responsive, not accessible…

We love a slider so we don’t think they’re going to disappear so soon.

News, tips and reviews from one of Britain's leading web hosting companies