VividVisions • information design

WordPress: Add iframes to your post using custom fields and shortcodes

The visual editor of WordPress (TinyMCE) loooves to remove iframes from the content. This can be extremely annoying when you want to add Google Maps or other iframe-based widgets to your post. There are several approaches to a solution:

  • Turn off the visual editor
    No problem for someone who has a good grasp of HTML. Not quite a solution, more of a workaround.
  • Edit the TinyMCE configuration files
    The required changes are simple but could be lost with the next update of the editor.
  • Use plugins
    I’m sure, there are tons of WordPress plugins which address exactly this issue but more plugins also mean more maintenance. Especially, when there is a much simpler solution.

Add the following code to the functions.php file of your theme:

function field_func($atts) {
   global $post;
   $name = $atts['name'];
   if (empty($name)) return;

   return get_post_meta($post->ID, $name, true);
}

add_shortcode('field', 'field_func');

Now you can display the value of a custom field in your post by adding the shortcode [field name=name-of-your-custom-field] to your content at the position where you would like it to be shown. Just make sure that the shortcode stands alone on a line, otherwise WordPress would wrap it in a paragraph, which would result in invalid HTML.

To add an iframe, simply paste the HTML code into the ”value” area of your custom field, like shown here:

WordPress field function

Voilá. Your iframe (or any other HTML code for that matter) will not be removed from your post and you can edit the code without having to switch to the HTML mode.

Update: You’ll need at least WordPress 2.5 to be able to use shortcodes.


The Flying Spaghetti Monster as custom shape for Photoshop

Flying Spaghetti Monster as Photoshop custom shapes

Have you ever wanted to include the likeness of the Flying Spaghetti Monster in your artwork? Just download the custom shapes I created and  go in peace to love and serve the FSM. RAmen! ;-)


To Mark The Occasion: Obamiconise yourself!


Apple iPhone 3G vs. Palm Prē

I know, it’s a bit early to to pit the iPhone against the Prē, since the latter hasn’t even come out yet. But having been a Palm user for years, I was very excited to learn about the Prē, which could be the first real competitor to the iPhone. Let’s compare the two devices.

Comparison table

apple-iphone.png
Apple iPhone 3G
Palm Prē
Palm Prē
Size (w × h × d) 62.1mm × 115.5mm × 12.3mm
(2.4 inches × 4.5 inches × 0.48 inch)
59.5mm × 100.5mm × 16.95mm
(2.3 inches × 3.9 inches × 0.67 inches)
Weight 133g (4.7 ounces) 135g (4.76 ounces)
Display
  • 3.5 inches
  • 320 x 480 pixels
  • 16,7 m. colours
  • 3.1 inches
  • 320 x 480 pixels
  • 16,7 m. colours
Multitouch support Yes Yes
Physical keyboard No Yes
Operating system Mac OS X for iPhone webOS
3G Yes Yes
EVDO No Yes
GPS Yes Yes
WLAN (WiFi) 802.11b/g 802.11b/g
Digital Camera 2.0 megapixels 3.0 megapixels
Camera flash No LED flash
Memory 8GB/16GB 8GB
USB mass storage support No Yes
Removable battery No Yes
Modem use No Yes
Bluetooth Bluetooth 2.0, EDR Bluetooth 2.1, EDR, A2DP stereo
Audio formats
  • AAC, Protected AAC
  • MP3, MP3 VBR
  • Audible (formats 2, 3, and 4)
  • Apple Lossless
  • AIFF
  • WAV
  • MP3
  • AAC
  • AAC+
  • AMR
  • QCELP
  • WAV
Video formats
  • MPEG-4
  • H.264
  • MPEG-4
  • H.263
  • H.264
Connectors
  • 3.5mm stereo headphone jack
  • 30-pin dock connector
  • 3.5mm stereo headphone jack
  • MicroUSB with USB 2.0 Hi-Speed
Sensors
  • Accelerometer
  • Proximity
  • Ambient light
  • Accelerometer
  • Proximity
  • Ambient light
Data sources apple.com palm.com

Openness

Palm adopted a far more user friendly and less industry-imposed approach than Apple:

  • USB mass storage (disk mode) support
  • Bluetooth with A2DP stereo standard support
  • Modem use
  • Removable battery
  • MicroUSB connector

Palm seem to have listened, because these features are among the most longed-for by iPhone users.

The keyboard

The physical keyboard of the Prē could be a selling point for people who are used to their Treo or Blackberry keyboards but in my opinion it can’t keep up with the virtual keyboard of the iPhone in terms of universal applicability and, of course, sexiness. Seeing the whole screen and having physical feedback while typing may be advantages of the hardware keyboard, but I don’t miss that on the iPhone.

I guess it is simply a matter of taste and I think it won’t be long until we see a successor of the Prē with a touch screen keyboard, utilising the promising Swype technology, which will hopefully also be available system-wide on the iPhone soon.

The camera

Its digital camera is a real weak point of the iPhone. It’s slow and far too sensitive to motion, most photos are blurry. The Prē features a 3 megapixel camera with a built-in LED flash which will hopefully provide for better photos. Unfortunately, I haven’t found any information indicating whether you can record films with the Prē or not.

Mac OS X vs. webOS

On the iPhone you can only run one application at a time for whatever reason, despite the multitasking-capable operating system. According to Palm, the Prē has been built with multitasking in mind. You can leave applications open, switch between them and even receive notifications from them when they are in the background, without distracting you too much from your current task.

Furthermore, the Prē promises to integrate the web wherever possible. For instance: The contact list not only shows you your locally stored contacts, but also the ones from Facebook, GMail and the like and combines the duplicates. Nice!

Above all, the Prē supports copy & paste. Yay! ;-)

iPhone SDK vs. Palm Mojo SDK

Only a few details have been released on the Palm Developer Network about their new software development kid named ”Mojo”:

Palm webOS applications are easy to write using Mojo, a new application framework based on the HTML 5, CSS and JavaScript standards that web developers already know and love. WebOS applications are installed and run directly on the device at native speed and have access to a wide range of device services.

Being able to develop applications for the Pre with my everyday means sounds exciting and has the potential of attracting hundreds of thousands other web developers. But Palm has yet to sell a decent number of their device to really be interesting to them, which will not be an easy task.

Conclusion

The Prē promises to be an exciting device and has the potential of being a serious competitor to the iPhone. If it proves to be as good as Palm advertise, I definitely will consider trading my iPhone for it. But it also remains to be seen, how Apple react to the Prē. At best, they will finally remove those silly restrictions from the iPhone and add features like the USB mass storage support.

More about the Palm Prē


The Frenzic Phenomenon (Comic)

The Frenzic Phenomenon

Check out Frenzic for Mac and/or iPhone. Be warned: it is highly addictive! ;-)

Twitter

Loading my tweets...