Adds some adjustments to the media order and allows this script to work for edit page as well.