This little blog will have musings on doing information technology work in a complex world.
MMWW — Media Metadata Workfilow Wizard Plugin for WordPress 3.4+
November 25, 2012
Uncategorized audio, exif, id3, image, iptc, media, mp3, pdf, plugin, wordpress, xmp 2 Comments
I created this plugin based on material from the Jetpack, Audio Player, and ImageEXIF plugins. I also used the Zend Media Framework.
I wrote it to scratch a personal itch: I handle a lot of media on a couple of sites I manage; we routinely publish audio and image files. Copying metadata from the files to WordPress is a nuisance, and this plugin is designed to remove that nuisance.
The plugin’s purpose is to integrate the fancy metadata that lives in modern media files with WordPress’s attachment metadata, so as to automatically populate the title and caption fields.
There’s a broad variety of metadata in media files. The Adobe tool chain (including Acrobat, Photoshop, Lightroom, and Bridge) insert xmp data: that’s the Adobe universal media format. Image, audio, and PDF files processed by Adobe end up with xmp descriptive metadata in them.
MP3 audio files also contain ID3 metadata. JPEG files contain EXIF metadata. And some files also contain IPTC Data.
The MMWW plugin attempts to make sense of this data.
Version 0.9.0 is an early release. If you use it I hope you’ll send me any media files that aren’t interpreted properly: it’s impossible for an independent developer to have very many makes and models of camera, recorder, and media software.
Thanks!
Useful links about WP plugin development
October 28, 2012
PDF metadata http://framework.zend.com/manual/1.12/en/zend.pdf.info.html
From the CODEX
http://codex.wordpress.org/Writing_a_Plugin
Hints and tips
http://wp.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/
Best practices
http://wp.smashingmagazine.com/2010/07/30/lessons-learned-from-maintaining-a-wordpress-plug-in/
Intro catalog
http://wpmu.org/how-to-write-a-wordpress-plugin-12-essential-guides-and-resources/
Coding pitfalls
http://planetozh.com/blog/2009/09/top-10-most-common-coding-mistakes-in-wordpress-plugins/
WordPress coding standards (from the codex)
http://codex.wordpress.org/WordPress_Coding_Standards (single quotes where possible, tab indents, K&R braces,
Setup stuff
Installing server with PHP http://vertstudios.com/blog/php-apache-installation-tutorial/
Setting up to debug http://robsnotebook.com/php_debugger_pdt_xdebug
<!–[if lt IE 7]>
<![endif]–>
Some nice progress!
October 22, 2012
Merrilee has done a nice post for her organizing business. I wonder if she fixes up hard drives full of random old doc files?
Another Test Post
September 17, 2012
Test post.
August 18, 2012
I’ve been to Central America. Here’s where the Jesuits were slaughtered by the American government’s proxies during the civil war. It’s at the University of Central America in San Salvador.
The point of this post was to test the uploading of dirty great hi res jpgs. It worked.
SQLFIDDLE
July 5, 2012
What’s a date?
July 4, 2012
SQL Time Processing Leave a comment
What is a date? This seems like a silly question. Indeed, if you are an independent business person in Arizona in the USA, it is a silly question. A date is, for example, the seventh of September, 2011 (“2011-09-07”). It describes a period of 24 hours that starts at midnight and ends just before midnight. If you only care about dates in Arizona, you’re in good shape.
But Arizona does not switch between daylight savings time and standard time. So, each day is 24 hours long. In much of the rest of the world there’s a day in the spring — the “spring forward” day — that’s 23 hours long. The hour from 2am to 3am is simply missing. There’s another day in the fall that’s 25 hours long. On that day the hour from 2am to 3am repeats itself.
Even if you’re located in Arizona, you probably correspond with people in other time zones. This makes it even harder to pin down what a day is. So, we need to make it clear when designing databases and the associated software.
When we design, for example, a date_of_sale field for a data base, we need to qualify that by acknowledging that is is in local time at the place the sale was made. Whether or not we explicitly acknowledge that, it’s still true.
So, when we make a sale on 2011-09-07, we can put that particular into a MySQL column with the datatype of DATE. Then it is available for all kinds of querying and arithmetic. For example.
The number of days since the sale:
SELECT DATEDIFF(CURDATE(),date_of_sale) AS number_of_days
Sales made on a particular day:
SELECT * FROM table WHERE date_of_sale = CAST('2011-09-07' AS DATE)
Sales made within seven days of a particular day:
SELECT * FROM table WHERE date_of_sale >= CAST('2011-09-07' AS DATE) AND date_of_sale < CAST('2011-09-07' AS DATE) + INTERVAL 8 DAY
Notice the way the range of dates is selected in the last example. We might be tempted to use the SQL BETWEEN operator to choose a range of dates. While this sometimes works, it is a bad habit to get into: it simply doesn’t work when we work with DATETIME information. A particular day starts at midnight, and ends just before midnight on the next day. The form of query in the example recognizes that truth.
Similarly, if we are asking for sales made on a particular day, it would be better practice to use this query:
SELECT * FROM table WHERE date_of_sale >= CAST('2011-09-07' AS DATE) AND date_of_sale < CAST('2011-09-07' AS DATE) + INTERVAL 1 DAY
This query will be sure to pull in the whole day.
If we want to display the date of sale in a human-friendly way, we can use, for example,
SELECT DATE_FORMAT(date_of_sale, '%W, %M %e, %Y') AS visible_date FROM table
This will display the date as “Wednesday, September 7, 2011”). There are many ways of formatting dates and times, shown here. They adhere to the locale — the local language — in use. For example, if you issue this command to set the language to Spanish and the locale to Mexico:
SET lc_time_names = 'es_MX'
and then issue the above SQL statement again, you will get “miércoles, septiembre 7, 2011” which is the correct display for Mexican Spanish.
On the other hand, if you issue this command with a text string containing an incorrectly formatted date, you’ll get a NULL result.
SELECT DATE_FORMAT('07/09/2011', '%W, %M %e, %Y') AS visible_date
The important thing is to make sure your date information is stored in your database in a DATE item. If it is you have access to all kinds of computations. If your dates are stored as text strings you don’t.
Processing dates and times in SQL
July 4, 2012
SQL Time Processing Leave a comment
I’ve spent too many working days figuring out how to handle dates and times in relational data base management systems. From looking at the questions on stackoverflow.com it’s obvious that a lot of people have the same kinds of questions and confusions I have.
I’m a lazy programmer. I’d much rather do this stuff right than do it over, and I don’t think I’m alone.
A big challenge of this date and time work is the lack of useful standardization for the working programmer. Oracle handles dates and times one way, MySQL handles them a different way, PostgreSQL another way, Microsoft applications another way, Unix and Linux yet another way, and so forth. (My British schoolteacher would have said, etcetera, etcetera, ad nauseam.) It has ever been so: the ancient Hebrews and Babylonians had their own calendars just like various software systems do now. Then, on top of that, we have time zones, the international date line, and leap seconds.
The conflicting ways of denoting the passage of time offer the software developer a stark choice.
- Swear fealty to one of the systems for marking dates and time, and forget about the others
- Go all postmodern and multicultural, and try to make software that will work with more than one system
I prefer the postmodern approach. But, either approach is hard to do right. The first step to doing any of this the lazy way is to get the concepts right.
There’s a fine book on this topic by Richard T. Snodgrass called Developing Time-Oriented Database Applications in SQL (San Francisco: Morgan Kaufman, 1999). It’s out of print, but Prof. Snodgrass has generously made it available online.