I do take requests for SPLOT features; the whole evolution of them has been propelled by ideas people have sent me.
Readers should ask, “What The Hell is a SPLOT?” Good question, I have a SPLOT that answers that question (google recursion).
Before plopping the details, I should acknowledge Reclaim Hosting for starting in April, a year long mini fellowship to support SPLOT development and integration into their hosted solutions. We are working on c-panel installers for pre-build SPLOTs. It’s mini, and I still am thankful for any support people can send via the cheesy donate buttons below (I hate groveling for this). The more support I get, the more time I can put into developing and sharing stuff that is free in both price and liberty to use.
Okay, on to the SPLOT features.
Links to Media By Selected Licenses
For both the TRU Collector (for images) and the SPLOTbox (for audio and video), sire owners have options to either request or require (or not ask at all) for a re-use license for media added to one of these spots (this was, in history, the reason for the very first version of TRU Collector).
Daniel Villar from Coventry University asked a while ago if there was a way to have links that would should all items with a particular license.
In theory yes, since the licenses are stored as custom fields for each post. Before jumping into the code, I looked for plugins that might do the job, and got the WP Custom Fields Search one working. It created a sidebar widget, where I could create a drop down menu with the names and values for each custom post litem for the custom field “license” (If you run one of these site, use Screen Options in the tp right of your dashboard to enable the view of custom fields, its handy to know what is stored under the hood).
While it worked, I prefer to find approaches that don’t rely on plugins. And it was not that complex. It first means adding to the themes functions.php
something that allows ms to send a variable for the license required to the post query request.
// ----- add allowable url parameters add_filter('query_vars', 'trucollector_queryvars' ); function trucollector_queryvars( $qvars ) { $qvars[] = 'flavor'; // flag for type of license return $qvars; }
So now on any url I can append a ?flavor=cc-by
… which does nothing until I set up a page to deal with it.
My approach was to create a new template page-licensed.php
(source code) that is called for any page with a url name of /licensed
My themes automatically create these Pages when the themes are activated; if you update an existing TRU Collector site, you can either activate another theme and then reactivate TRU Collector, or create a new Page with a slug/url name licensed
.
The way it works is, when you just go to the page, like http://splot.ca/collector/licensed/, it generates a list of all possible URLs to provide the desired view:
You can edit the page to put whatever content you like at the top (and change the title). I’m not sure I would use this directly on the site. But you can use the URLs to add to menus or widgets.
For example, see all images on this site licensed Public Domain or ones licensed CC-BY, or ones where the rights status is unknown.
Now the actual URLs look like http://splot.ca/collector/licensed?flavor=pd
or http://splot.ca/collector/licensed?flavor=cc-by
. But I figured out some extra hijinks to make these pretty links:
// ----- rewrite rules for licensed pretty urls add_action('init', 'trucollector_rewrite_rules', 10, 0); function trucollector_rewrite_rules() { $license_page = get_page_by_path('licensed'); if ( $license_page ) { add_rewrite_rule( '^licensed/([^/]*)/?', 'index.php?page_id=' . $license_page->ID . '&flavor=$matches[1]','top'); } }
so they work as http://splot.ca/collector/licensed/pd
and http://splot.ca/collector/licensed/cc-by
.
There is one small hitch… for these links to work, you need to go to the Settings -> Permalinks and just click the save button to regenerate the rewrite rules (if you do not the links will generate 404 errors).
This is also at play on SPLOTbox- see the demo site http://splot.ca/box/licensed/.
I think this is rather useful, so thanks Daniel for the idea.
SPLOT Box Support for Internet Archive Content
This is another request from Daniel (he keeps sending good ones), to provide a way for SPLOTbox to use media from the Internet Archive video collection (bonus it seems to work for audio).
The current use of vimeo and YouTube is that WordPress supports auto embed for these sources, meaning embeds can be generated by simply sending the URL of the page source. There are ways to add support for other sources using <a href="https://codex.wordpress.org/Function_Reference/wp_embed_register_handler">wp_embed_register_handler</a>
.
This means being able to write a regex pattern to pull info from the source URL for the media and generate the embed code. I’d never done this before, all the more reason to try.
So I have a video on the Lone Ranger at https://archive.org/details/enter_the_lone_ranger
and I can see the embed code is
So it seems all easy, I just need to take the source URL and substitute embed
for details
in the embed code.
it took some head banging with the demo from the WordPress Codex and stackoverflow scouting to find the right way to do this. My approach is try try, fiddle, try, fiddle until I get rid of the error messages and maybe the thing works. My stumbling point was really my regex expression.
But this will work for any site you want to make Internet Archive videos automatically embed in WordPress:
// Set up oembed for Archive.org videos add_action( 'init', function() { wp_embed_register_handler( 'archiveorg', '#https?://archive\.org/details/(.*)#i', 'wp_embed_handler_archiveorg' ); } ); function wp_embed_handler_archiveorg( $matches, $attr, $url, $rawattr ) { $embed = sprintf( '', esc_attr( $matches[1] ) ); return apply_filters( 'embed_archiveorg', $embed, $matches, $attr, $url, $rawattr ); }
I even got regex fancy using https?
meaning it will work with a URL that is https
or just http
.
It’s working now on the SPLOTbox demo site http://splot.ca/box/ so you can try it out:
New feature coming soon for the SPLOTbox media juke box collector; support for audio/video content from the Internet Archive- live now at https://t.co/Z8EappNHi3 pic.twitter.com/dTRg27o8I2
— Alan Levine (@cogdog) May 4, 2018
Get Your New SPLOT Themes
These updates are now available:
- TRU Collector https://github.com/cogdog/tru-collector
- SPLOTbox https://github.com/cogdog/splotbox
I do all my updates so they won’t mess with previous versions, you should be able to upload to your site’s wp-content/themes
directory to update.
If you don’t enjoy ftp-ing … what’s wrong with you? 😉 I suggest using the Easy Theme and Plugin Upgrades plugin which allows you to upload the theme from a downloaded ZIP file in the WordPress interface (like when you first added it)… WordPress does not allow you to upload a ZIP version of theme to update it, but this plugin does the end around you need.
When we get things working with Reclaim Hosting’s plans to off these as cpanel installs, the normal WordPress automatic update will also update the themes.
Now that is a great thing, and why I am excited to be collaborating with them (besides being the coolest company on earth, they own a freaking video store!)
If you are not on the SPLOT train yet, play around with the ones at http://splot.ca. and my ears are open for good ideas that will improve them for others.
SPLOT on.
Featured Image: Pixabay image by 3dman_eu shared into the public domain using Creative Commons CC0
Be careful modding the query without checking the page as it can cause all the fun 🙂
I’ll ping you some code monday which skips the adding of query vars and so on
I await your lessons, sensei.