Home
Blog
Showcase
Community
Introduction
Overview
Introduction To TinaCMS
Getting Started
Using the Tina Editor
FAQ
Core Concepts
Content Modeling
Data Fetching
Visual Editing
Querying Content
Overview
Writing custom queries
Editing
Overview
Markdown & MDX
Block-based editing
Single Document Collections
Customizing Tina
Overview
Validation
Custom Field Components
Custom List Rendering
Format and Parse Input
Filename Customization
Before Submit function
Going To Production
Overview
Tina Cloud
Self-Hosted
Drafts
Overview
Draft Fields
Editorial Workflow
Guides
Overview
Framework Guides
Separate Content Repo
Querying Tina Content at Runtime
Internationalization
Migrating From Forestry
Further Reference
Overview
Config
Schema
Overview
Collections
Fields
Templates
Field Types
Overview
string
number
datetime
boolean
image
reference
object
rich-text
The "tina" folder
The TinaCMS CLI
Media
Search
Content API
Tina's edit state
The "tinaField" helper
Self-Hosted Components

image

type ImageField = {
label: string
name: string
type: 'image'
/** See https://tina.io/docs/extending-tina/overview/ for customizing the UI **/
ui?: {
label?: string
description?: string
component?: FC<any> | string | null
parse?: (value: string, name: string, field: F) => any
format?: (value: string, name: string, field: F) => any
validate?(
value: string,
allValues: any,
meta: any,
field: UIField<F, Shape>
): string | undefined | void
}
}

Example

export default defineConfig({
//...
schema: {
collections: [
{
name: 'posts',
label: 'Blog Posts',
path: 'content/posts',
format: 'mdx',
fields: [
{
type: 'image',
label: 'Hero image',
name: 'imgSrc',
},
// ... other fields
],
},
],
},
})
// ...

Please see the media docs for how to set up media in your site.

Customizing an image formatting

If you need to customize how an image is formatted in a field, you can use the format & parse options.

//tina/config.ts
// fields
// ...
{
type: "image",
name: "heroImg",
label: "Hero Image",
ui: {
format(value) {
//add leading slash to value if it doesnt exist
return value.startsWith("/") ? value : `/${value}`;
},
parse(value) {
//remove leading slash if it exists
return value.startsWith("/") ? value.slice(1) : value;
},
}
}

You can read more about format & parse here.

Last Edited: June 15, 2022

Product

Showcase
TinaCloud
Introduction
How Tina Works
Roadmap

Resources

Blog
Examples
Support
Media

Whats New
TinaCMS
TinaCloud
Use Cases
Agencies
Documentation
Teams
Jamstack CMS
Benefits
MDX
Markdown
Git
Editorial Workflow
Customization
SEO
Comparisons
TinaCMS vs Storyblok
TinaCMS vs Sanity
TinaCMS vs DecapCMS
TinaCMS vs Contentful
TinaCMS vs Builder.io
TinaCMS vs Strapi
Integrations
Astro
Hugo
NextJS
Jekyll