Improved Google Folder Shortcode Plugin

creative commons licensed ( BY ) flickr photo shared by Steve Snodgrass

In December I wrote a tiny shortcode plugin that would let you embed Google Folders in WordPress. It was mainly to get around the iframe embed issues in WordPress Multisite. This interaction seems to make a number of faculty members pretty happy.

So tonight when I got a comment asking how you’d get the plugin to display a grid view instead of the list view I decided to take another look at things. The short answer is that you could not do that with the old plugin. Now that I’m pretending to write code and stuff I thought I might be able to fix that and it turned out to be fairly simple. While I was in there I also added the ability to manually set height and width parameters.

The new plugin is here. It doesn’t like it when I run both on the same blog (I assume because of the shared shortcode name) so this demo required that I turn off the older plugin.

To make the changes I followed the Codex advice on handling attributes.


function gdrive_shortcode($atts, $content=null) {
    $a = shortcode_atts( array(
         'id' => '', //make a name for the id of the folder
         'style' => 'list',  //make a name for the view style and assign it the default value "list"
    ), $atts); 
	return '<iframe src="' . $a['id'] . '#' . $a['style'] . '" frameborder="0" width="100%" height="500px" scrolling="auto"> </iframe>'; //return this code w the variables interwoven
add_shortcode( 'gdrive', 'gdrive_shortcode' ); //make your shortcode all official

This stuff still feels like magic to me. I realize how little actual skill and knowledge I posses in the scheme of things but it is amazing fun to be able to make things that function in the real world.

List View

Adding the opening and closing square brackets to this gets you the view below
gdrive id=”0B_9l84KvUJBWODM4YjY3MGMtZGMzMS00MjI0LTk0NGQtNDgxMTRjMmNlODZl” style=”list” width=”60%” height=”200px”

Grid View

Adding the opening and closing square brackets to this gets you the view below
gdrive id=”0B_9l84KvUJBWODM4YjY3MGMtZGMzMS00MjI0LTk0NGQtNDgxMTRjMmNlODZl” style=”grid” width=”100%” height=”300px”

No Style/No Height/No Width

Adding the opening and closing square brackets to this gets you the view below (it defaults to list view, 100% width, and 500px for height)
gdrive id=”0B_9l84KvUJBWODM4YjY3MGMtZGMzMS00MjI0LTk0NGQtNDgxMTRjMmNlODZl”

15 thoughts on “Improved Google Folder Shortcode Plugin

  1. Hi,
    I’ve been looking for a plugin like this.
    However I’m having a problem in actually showing the files on my website…
    It says “Error 404 Not found” where the list/grid should be.
    Anything I might have forgotten?

    Kind regards,

      1. Sorry for the late feedback. I had finals and totally focused on those.
        So I’m using the shortcode like this: [gdrive id=”0B6TjbmtN-l94WUF4MWFDaUdmQU0” style=”grid” width=”100%”]
        And this is the page that I want to show the google drive document(s):

        1. It works for me. I did have to make sure I got rid of the “pretty quotes.” Try the version below.

          [gdrive id="0B6TjbmtN-l94WUF4MWFDaUdmQU0" style="grid" width="100%"]

          1. Yes, it works now! Must have been the pretty quotes. Thanks a lot for helping me out and especially for making the plugin! 🙂

  2. Hi,
    I really loved your plugin. It does exactly what I needed.
    I’m using the “grid” view and works perfectly but I would like to change the size of the preview of the files inside because they’re very small!
    Setting the parameters of height and width only affects the size of the “window”.
    Is there any possibility to enlarge the icons inside?

    Thank you very very much.

  3. Awesome. Sounds and looks exactly to what I’m looking for, the only problem is I haven’t figured out what plugin to install and how to make it work. Just to let you know I’m a very basic WP user with the minimum knowledge about any programming, but I would love to try to do make this plugin work on my webpage, even if a little programming is needed.

    1. There’s a link to the plugin in the body of the post. Just download it from GitHub and upload it to your plugins and activate as normal. Directions on doing it from outside the plugin repository are at the bottom of this link.

    1. I can’t find any parameters listed that would apply. I’ve guessed at a few combinations but no luck so far. Using Google Sites as a test hasn’t given me any good parameters either.

  4. Tom, am I missing something blindingly obvious here? I’ve found the php file over on GitHub but my (hosted) wordpress won’t accept that as a plugin. I’ve tried uploading both as a php file and as a zip but either way it’s rejecting it. It sounds as though it’s just what I was looking for so I’m sure it must just be me being a numpty.

    1. Hey Andy,

      Are you seeing any errors? What exactly is happening?

      And when you say hosted, do you mean self-hosted (as opposed to which is what I’m seeing in your comment info)?

  5. Thanks so much for this! It was exactly what I was needing for my class website. I really appreciate that you provide this for free, since as a teacher I can’t afford to pay for things! 😀 You are an awesome guy!!

Comments are closed.