public function media_files() { return $this->with_blog_scope(function () { $sql = ' SELECT M.* FROM ' . MediaFile::table_name() . ' M JOIN ' . EpisodeAsset::table_name() . ' A ON A.id = M.episode_asset_id WHERE M.episode_id = \'' . $this->id . '\' ORDER BY A.position ASC '; return MediaFile::find_all_by_sql($sql); }); }