Off

WordPress Media Library Crashes Browser Tab in Chrome on Windows

Recently, one of our clients was having trouble with their WordPress site: when trying to add media from the Media Library to a post or page in Chrome on Windows, the browser tab would simply crash immediately upon attempting to load the media library. Basically the Media Library lightbox would open, then either right away as the image thumbnails started to load, or sometimes after about half of the thumbnails had loaded, the browser tab would crash completely. (The same problem materalized when trying to load the Media Library page in the backend of the site as well.)

Since I had no luck finding a solution by Googling this problem, I wanted to share my findings.

The problem, as it turns out, was that several large images that had been uploaded to the site the previous week were bogging down the media library, causing the browser tab to crash. These images were all over 4MB, and upon removing them from the server, the browser no longer crashed.

My solution was to optimize the images for or client and put them back on the server at a greatly reduced file size and put a limit of 4MB on the file size for future uploads, in order to prevent this from happening again.

Limiting File Upload Size in WordPress

I found lots of information and different techniques on how to limit the file upload size in WordPress, but unfortunately most of them either didn’t work at all, or failed to change the message on the upload screen that notifies the user of what the maximum file upload size is. For example, even though the file upload size was being effectively limited to 4MB, the message below the file upload input still said “Maximum upload file size: 8MB.” which isn’t very user friendly.

Here’s how I got it to work and update the maximum file size message – place the following line of code in your .htaccess file.

php_value upload_max_filesize 4M

 

Off

WordPress: Display Parent Page Title in the Title Tag

Recently we built a site where a large portion of the content was organized into sub-pages, each of which needed to display their parent page title in the template. After I finished building the site I realized that the parent page title should also be displayed in the <title> tag for SEO purposes. I had been using Yoast’s SEO plugin to display all my page titles in the following format:

<title>
  Page Title | Site Name
</title>

What I needed was for the top-level pages’ titles to stay the same while child pages’ titles to display like this:

<title>
  Parent Page Title — Page Title | Site Name
</title>

Since Yoast’s SEO plugin does not have a variable that can accomplish this, I had to edit my header.php template file and change this:

<title>
  <?php wp_title( '|', true, 'right' ); ?>
</title>

To this:

<title> 
 <?php 
   if($post->post_parent) { 
     $parent_title = get_the_title($post->post_parent); 
     echo $parent_title.' - '; 
   } 
  ?> 
 <?php wp_title( '|', true, 'right' ); ?> 
</title>

Display a child page’s parent page title in your title tag by copying and pasting the above code into your header.php template file.