# -*- coding: utf-8 -*-
from cms.models import Page
from django import template

register = template.Library()


@register.filter
def page_image(id):
    try:
        return Page.objects.get(pk=id).imageextension.image
    except:
        return None


@register.filter
def page_image_cropping(id):
    try:
        return Page.objects.get(pk=id).imageextension.cropping
    except:
        return None


@register.filter
def field_type(field):
    return field.field.widget.__class__.__name__
