Markdown extension to display and manipulate images on Cloudinary.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Markdown extension for Cloudinary

This is a 3rd party extension for Python Markdown library.
Enabling this extension, you can generate <img> tags that display images uploaded on Cloudinary.


The cloudinary template tag can be used in markdown text.

{% cloudinary "sample.jpg" %}
<img src=""/>

Transformation options are supported. Quotations around number value are necessary.

{% cloudinary "sample.jpg" width="100" height="150" crop="fill" %}
<img src=",h_150,w_100/sample.jpg" width="100" height="150"/>

The given options are directly passed to CloudinaryImage.image() method. The extension does not check given options are valid or not.


You can install the extesion and its dependencies via pip.

pip install python-markdown-extesion


Python code to convert markdown text to HTML text using this extension.

import cloudinary
import markdown
from mdx_cloudinary.extension import CloudinaryImageExtension


markdown_text = '{% cloudinary "sample.jpg" %}'

html = markdown.markdown(markdown_text, extensions=[CloudinaryImageExtension()])

Django Template Tag

If you need a Django template filter to convert markdown text to HTML, the template tag code is as follows:

from django import template
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe
import markdown
from mdx_cloudinary.extension import CloudinaryImageExtension

register = template.Library()

md = markdown.Markdown(extensions=[CloudinaryImageExtension()])

def md2html(value):
    html = md.convert(value)
    return mark_safe(html)

Loading the template tag, you can use md2html filter in your template.

{{ markdown_text_variable|md2html }}

Note: Your cloud name must be configured in or via environment variable.