Embed Google Drive on WordPress

Download Plugin: https://github.com/woodwardtw/gfolder_embed

Source article

Author: Tom Woodward

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.

12345678910<?php 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="https://drive.google.com/embeddedfolderview?id=' . $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”
https://drive.google.com/embeddedfolderview?id=0B_9l84KvUJBWODM4YjY3MGMtZGMzMS00MjI0LTk0NGQtNDgxMTRjMmNlODZl#List

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”
https://drive.google.com/embeddedfolderview?id=0B_9l84KvUJBWODM4YjY3MGMtZGMzMS00MjI0LTk0NGQtNDgxMTRjMmNlODZl#grid

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”

Leave a Reply

Another post

Embed Google Drive on WordPress

Download Plugin: https://github.com/woodwardtw/gfolder_embed Source article Author: Tom Woodward In December I wrote a tiny shortcode plugin

Bekerja di rumah

Bekerja di rumah sudah biasa bagi saya yang berprofesi sebagai UI Designer dan wordpress konsultan.