Replace all ereg with preg

Contributed by Iver Odin Kvello
PHP variable undefined warnings

Contributed by Iver Odin Kvello
Sometimes there is no S3 post meta info

Contributed by Iver Odin Kvello
Unnecessary pass by reference

Contributed by Iver Odin Kvello
Ensure S3 post meta is removed

Contributed by Iver Odin Kvello