protected function updateTinyMCEInContent(Database $db)
    {
        $this->write('  + Updating medias in tinyMce attributes');

        $this->checkExecute($db->execute(
            $this->getJSFunctions() . '

            db.content.find({}).snapshot().forEach(function(content) {
                var updated = false;

                for (var attributeName in content.attributes) {
                    if (content.attributes.hasOwnProperty(attributeName) && "wysiwyg" == content.attributes[attributeName].type) {
                        var pattern = /\[media=([^\]\{]+)\]([^\]]+)\[\/media\]|\[media=\{"format":"([^"]+)"\}\]([^\]]+)\[\/media\]/g;
                        var matches = pattern.execAll(content.attributes[attributeName].value);

                        for (var i = 0; i < matches.length; i++) {
                            var mediaId = getMediaIdFromMatch(matches[i]);
                            var format = getMediaFormatFromMatch(matches[i]);
                            content.attributes[attributeName].value = updateAttribute(content.attributes[attributeName].value, mediaId, format, getMediaAlt(mediaId, content.language));
                            updated = true;
                        }
                    }
                }

                if (updated) {
                    db.content.update({_id: content._id}, content);
                }
            });
        '));
    }