Posts Tagged “wordpress”

Fixing a Lightbox issue

I ran into a problem using Lightbox plugins on my blogs. I’m currently running modified versions of the Constellation Theme, which is full of HTML 5 goodness and styled to re-flow according to screensize (ie is mobile adaptable).

No matter what Lightbox plugin I’d been using since upgrading WordPress to the latest version (3.3), the overlay was showing a margin and an offset as exemplified below:

This is because of the way the overlay is codded to effect the < body > tag. Constellation styles the < HTML > tag in ways usually reserved for < body > so by making a change to the Lightbox Javascript file, one can correct this behavior.

In this case, I’m using Ulf Benjaminsson’s wp-jquery-lightbox plugin.

=== Fix ===

1. In `wp-content/plugins/wp-jquery-lightbox/jquery.lightbox.min.js`

2. search for “body”, and it’s found twice as a string in code like the following:

1) ....;a("body").append ....
2) ....;a("body").append ....

which correspond to lines 67 and 71 in the non-minified file.

Change these to HTML:

1) 1) ....;a("html").append ....
2) ....;a("html").append ....

Private Posts: using a lock icon

I have some private posts here and there on my various WordPress blogs. WordPress is coded to display the word ‘Private:’ in front of whatever your title is, like this:


I had the thought that it might be better to replace the word with a lock icon, so that it would look like this:


In order to do this, I looked into the WordPress Codex and found the function that inserts the word ‘Private’.

  1. WordPress’ get_the_title(); function inserts the string `Private`
  2. this function is coded between lines 104-120 of the post-template.php file, located in the wp-includes directory.
  3. line 115 reads like this $private_title_format = apply_filters('private_title_format', __('Private: %s'));

Now that I knew what to change, I Googled for a lock image and found a no-copyright black one on Wikipedia, at size 360 x 360 pixels. I resized it to 16 x 16, and uploaded to the wp-includes folder. (I didn’t see why it should be in another).

Next, I coded it with an absolute url, since WordPress’s various functions to make clean urls meant that simply using <img src="lock.png"> didn’t work. Line 115 in post-template.php now looked like this example:

$private_title_format = apply_filters('private_title_format', __('<img src="//example.com/wordpress/wp-includes/lock.png"> %s'));