private function mediaToJson($collection)
    {
        $result = [];
        foreach ($collection as $media) {
            $content = $media->getContent();

            if (null !== $draft = $this->getClassContentManager()->getDraft($content)) {
                $content->setDraft($draft);
            }

            // we also need to load content's elements draft
            foreach ($content->getData() as $element) {
                if (null !== $draft = $this->getClassContentManager()->getDraft($element)) {
                    $element->setDraft($draft);
                }
            }

            $mediaJson = $media->jsonSerialize();
            $contentJson = $this->getClassContentManager()->jsonEncode($media->getContent());
            $mediaJson['image'] = $contentJson['image'];
            $result[] = $mediaJson;
        }

        return $result;
    }