> For the complete documentation index, see [llms.txt](https://degreetpro.gitbook.io/degreet-telegram/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://degreetpro.gitbook.io/degreet-telegram/additional/edit-media.md).

# Edit Media

{% tabs %}
{% tab title="TypeScript" %}

```typescript
import { Photo, Video, Document } from 'degreet-telegram/src/creators'
import { IContext } from 'degreet-telegram/src/types'
import * as path from 'path'

// You can use new Video, new Document also

bot.onClick('edit', async (ctx: IContext): Promise<any> => {
  try {
    // edit local photo
    await ctx.answer.edit(
      new Photo('path', path.resolve(__dirname, 'mountain.jpg'))
        .setCaption('Hello, world!')
    )
    
    // edit photo by url
    await ctx.answer.edit(
      new Photo('url', 'https://idsb.tmgrup.com.tr/ly/uploads/images/2020/11/25/thumbs/800x531/74707.jpg')
        .setCaption('Hello, world!')
    )
  } catch (e: any) {
    console.error(e)
  }
})
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const { Photo, Video, Document } = require('degreet-telegram/build/creators')
const path = require('path')

// You can use new Video, new Document also

bot.onClick('edit', async (ctx) => {
  try {
    // edit local photo
    await ctx.answer.edit(
      new Photo('path', path.resolve(__dirname, 'mountain.jpg'))
        .setCaption('Hello, world!')
    )
    
    // edit photo by url
    await ctx.answer.edit(
      new Photo('url', 'https://idsb.tmgrup.com.tr/ly/uploads/images/2020/11/25/thumbs/800x531/74707.jpg')
        .setCaption('Hello, world!')
    )
  } catch (e) {
    console.error(e)
  }
})
```

{% endtab %}
{% endtabs %}
