Allowing g2embed to open a gallery directly

October 16th, 2007

Sometimes you want embedded gallery to open a gallery in the blog frame, sometimes  you want it just to link to the full gallery and have it completely redraw the screen.  The difference is a link in your imageblock that is either /gallery/v/SomeAlbum vs. /blog/v/SomeAlbum.  The first will render the album in a new gallery frame.  The second will render the album within your blog entry.  The embedded developers requested an override so that the G2 url creation method could do either.  If you want your imageblock to render the album in a new frame make the following changes:

In ImageBlockHelper.class, go to near the bottom of the loadImageBlocks() method.  Below the line that says $ImageBlockData[’forceFullUrl’]=1, add another variable to the ImageBlockData array: $ImageBlockData[’forceDirect’]=1.  This will send a message to the template to force a direct url (instead of a blog url) when creating the url.  You have to do one more thing though.  The template itself needs to be told what to do with the new data member.  Open up ImageBlock.tpl and find the calls to g->url.  Change them so that there is one more argument passed in: {g->url arg1=”view=core.DownloadResize” arg2=”itemId=`$block.id`”
forceFullUrl=$ImageBlockData.forceFullUrl forceDirect=$ImageBlockData.forceDirect}

forceDirect will tell the url creation method to only use the /gallery url instead of the /blog url.  Your image blocks will now all open into a new gallery frame.

Keeping the G2 image placement window from closing on insert

January 24th, 2007

One thing that annoyed me about the tinymce plugin for photo placement into blog entries from g2 was that everytime you insert an image, the window closes, then you have to browse back to the gallery page you were using and insert another image. I fixed this in the g2 plugin. The window will now stay open and will insert one image after another.

To use this hack download the following files:

functions.js
popup.js

Copy both files into your blog/wp-includes/js/tinymce/plugins/g2image/jscripts directory. To make it more useful, set the preferences in the WPG2 preferences screen so that you don’t have to click the “insert” button, but you just click an image to insert it (Default Click Action ->Instantly insert using default settings). Then click away and watch the images show up in your blog entry.

Bug fixes for DownloadResize and ImageBlockHelper

January 24th, 2007

I fixed a couple of bugs relating to displaying images with no resizes. Here are the most recent files:

DownloadResize.inc
ImageBlock.tpl
ImageBlockHelper.class.txt

DownloadResize.inc goes in gallery/modules/core.

ImageBlock.tpl goes in gallery/modules/imageblock/templates.

ImageBlockHelper.class.txt goes in gallery/modules/imageblock/classes and must be renamed to ImageBlockHelper.class.

Dispaying resizes in blog entries

January 19th, 2007

I finally got WPG2 to send a resize to a blog entry in an imageblock instead of sending either a thumbnail or the full size image. I hacked the ImageBlockHelper.class file to use loadEntitiesById and fetchResizesByItemIds instead of fetchPreferredsByItemIds. Now if you select an images size in your WPG2 settings that is bigger than your thumbnail, say 450 pixels, it will grab the smaller resize instead of the biggest one.

To do this, copy this file to your gallery/modules/imageblock/classes directory. Backup your current ImageBlockHelper.class file and then rename ImageBlockHelper.txt to ImageBlockHelper.class. Then go into your blog site admin, click the WPG2 link in nav bar, then choose “Blog Image Options” and set your “WPG2ID/WPG2 Tag Thumbnail Maximum Size:” to something bigger than 150. I set mine to 450, but your blog might have a different width.

Note for this to work, you must have image resizes in your gallery and the resizes should be built. If you don’t, I don’t know what will happen….

Getting Lightbox to work with resizes

January 7th, 2007

***Note: The files linked to below have been updated. Please go to this post to get the newest files.***

I’ve spent my entire Sunday today working on getting Lightbox to work with the Siriux plugin and also getting it to deal with the resizes that G2 creates. G2 creates the thumbnail and any resized image that you specify in your gallery when you upload your images. Unfortunately, up until version 2.2 it’s been very hard (or impossible) to actually extract the resized jpg image outside of an ImageBlock wrapper which has made it impossible to display the resized image in Lightbox since Lightbox wants the actual jpg, not the html with a jpg embedded in it.

Here’s how I got it to work. I’m still not super happy with how the embedded gallery looks, but I’ll hack on that some more later.

I assume the following:

1) You have Wordpress, WPG2 and Gallery 2 version 2.1 installed and working. You’ll also need to download and install the Lightbox WP plugin for Wordpress.

2) You have access to your server so that you can directly edit the php files that make these apps work.

3) You *BACKUP* any files that I ask you to change *before* you change them. I’m not responsible if you hose your Gallery or Wordpress installation. Also, I’ve only tried this on my server. I haven’t tested this for the world. It is a hack, so you should treat it like a hack (i.e. with caution).

First, upgrade to Gallery v2.2. This is pretty pain free. Just follow the directions the Gallery developers site for upgrading.

Next, add this file to your gallery/modules/core directory. Make sure its named “DownloadResize.inc”.
Next, replace your gallery/modules/imageblock/templates/ImageBlock.tpl file with this file.

That should be it. Refresh your blog and try clicking on an image. Lightbox should bring the resized image up over the top of the blog entry. I had some weird behavior with embedded albums (i.e. a thumbnail link to an album) and the only way I could fix it was to disable, then re-enable the WPG2 plugin. If something doesn’t work, or if you find something I did needs re-explaining, let me know.

Once caveat I should mention is that the DownloadResize file takes the first resized image that you have. I only have a thumbnail and a 640×480 image, so it takes the 640 image. If you have multiple resizes, you’ll have to hack DownloadResize to get it to take the size you want.

Thanks to Shiner for helping me out a lot with the howto he published on his original hack.

New Development Site for OffHeGoes.net

December 20th, 2006

I’ve created this site with the intention of having a place to play with new stuff before making changes to my main site. Hopefully I’ll be able to figure out some cool stuff here using Gallery, Wordpress and the WPG2 plugin. If I do, I’ll share it for others to use. In the meantime, here are some pictures from the gallery.

IMG_6345

The Sawtooths in central Idaho.

IMG_6374

More Sawtooths

Test

The whole gallery