private function getPostRelatedMedia($id, $post, $postTypeSlug, $translatableFields)
    {
        $media = array();

        $mediaRelationTable = $postTypeSlug.'_media';
        // get the media relation joining the media table and the post
        $mediaRelationsResults = DB::table($mediaRelationTable)
            ->join('media', $mediaRelationTable.'.mediaID', 'media.mediaID')
            ->join($postTypeSlug, $mediaRelationTable.'.postID', $postTypeSlug.'.postID')
            ->where($mediaRelationTable.".postID", $id)
            ->select(
                'media.title as title', 'media.mediaID', $mediaRelationTable.'.mediaRelationID',
                $mediaRelationTable.'.postID', $mediaRelationTable.'.language',
                'media.description', 'media.credit', 'media.type', 'media.extension',
                'media.url', 'media.filename', 'media.fileDirectory', 'media.filesize', 'media.dimensions', $mediaRelationTable.'.field'
            )
            ->get();


        // the object media used for the media custom fields in the front end
        if ($post->featuredImageID) {
            $featuredImage = Media::find($post->featuredImageID);
            // set feature image if it exist
            if($featuredImage) {
                $media["featuredImage"][] = $featuredImage;
            }
        }
        if ($post->featuredVideoID) {
            $featuredVideo = Media::find($post->featuredVideoID);
            $media["featuredVideo"][] = $featuredVideo;
        }

        // loop throw the media relation and construct the $media object
        foreach ($mediaRelationsResults as $relation){
            if(in_array($relation->field, $translatableFields)) {
                $langArr = json_decode($relation->language);
                foreach ($langArr as $langKey => $lang){
                    if(!isset($media[$relation->field."__lang__".$langKey])) {
                        $media[$relation->field."__lang__".$langKey] = array();
                    }
                    if ($lang) {
                        array_push($media[$relation->field."__lang__".$langKey], $relation);
                    }
                }
            }else{
                if(!isset($media[$relation->field])) {
                    $media[$relation->field] = array();
                }
                array_push($media[$relation->field], $relation);
            }
        }

        return $media;
    }