How Media Manager inserts the image into the post...

Some users have been reporting that the Amazon image does not show up in a published review/entry. I have been working hard to get to the bottom of this. In the meantime, I thought I might expain how Media Manager publishing works in a hope that the information may ring a bell with those who are experiences these difficulties.

In the first iteration of Media Manager, I created and registered a text filter that when assigned to a post, would cause Media Manager to perform some formatting prior to the review/post being published. This was easy as pie to implement, but had the draw back of preventing others from using other text filters (like "Convert Line Breaks" or the more geeky "Markdown") when writing reviews. I hated this. So I rearchitected Media Manager to use callbacks instead.

There are two key callbacks that are reigstered. The first is a pre-save callback. This callback is executed when an MT::Entry object is being saved and that MT::Entry object is also a Media Manager review. If so, the callback added a block of header and footer HTML to the beginning and end of the post. When the Entry is loaded, the markup is there and is simply output to the screen. The markup contains all the necessary style information so that additional stylesheets do not need to be added to the blog's index template.

However, once this markup is in the body of the post, it presents the problem of being present inside the post when it is edited. Because I wanted to abstract the user away completely from this HTML (so that noone needs to know HTML in order to use Media Manager) I have one more critical callback. This callback is executed right after loading an MT::Entry object, and when the user is on the Edit Entry screen. If so, the markup I add using the first callback is removed. (Don't worry, it gets added back when you user saves the MT::Entry again).

This technique enables me to reuse the Edit Entry screen in its entirity. Which is incredibly useful and saves me a lot of time because it keeps me from having to create and support my own posting screen.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About Majordojo

"Majordojo" is the name under which Byrne Reese releases the software he writes. Byrne Reese is a father, a product engineer, an open source hacker and an employee of Six Apart.

 Subscribe to this site's feed

View Byrne Reese's profile on LinkedIn

Recent Comments