hexo.extend.tag.register('oss_image', function(args) {
    let { config } = hexo;

    let requestImage = args[0] || '';
    let versionCode = args[1] || '';
    if (requestImage.length === 0 || versionCode.length === 0) {
        return '';
    }
    let imageSrc = `${config.oss.endpoint}/${requestImage}?versionId=${versionCode}`;

    let attrs = [];
    attrs.push(`src="${imageSrc}"`);

    let altMessage = args[2] || '';
    attrs.push(`alt="${altMessage}"`);

    let classes = args[3] || '';
    if (classes.length !== 0) {
        attrs.push(`class="${classes}"`);
    }

    let width = args[4] || 0;
    if (width !== 0) {
        attrs.push(`width="${width}"`);
    }

    let height = args[5] || 0;
    if (height !== 0) {
        attrs.push(`height="${height}"`);
    }

    return `<img ${attrs.join(" ")} />`;
});