# How to replace custom kirbytags with standard ones?

**URL:** https://forum.getkirby.com/t/how-to-replace-custom-kirbytags-with-standard-ones/19193
**Category:** Questions
**Tags:** v3
**Created:** [August 28, 2020, 10:48am UTC](https://forum.getkirby.com/t/how-to-replace-custom-kirbytags-with-standard-ones/19193 "2020-08-28T10:48:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![hvsrmusic](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/hvsrmusic/32/2722_2.png) [@hvsrmusic](https://forum.getkirby.com/u/hvsrmusic)
#### Post date: [August 28, 2020, 10:48am UTC](https://forum.getkirby.com/t/how-to-replace-custom-kirbytags-with-standard-ones/19193/1 "2020-08-28T10:48:52Z")

</div>

Hi, I’m currently using my own custom kirbytags for embedding images and videos in the textarea fields.

Now, switching to the Kirby Editor, I’ve seen that my custom tags are not automagically converted, so I wonder which is the best way to programmatically replace my custom tags with the standard ones.

Example:  
I’m using (img:…) and (imgsmall:…) for images, (yt:…) and (ytsmall: …) for videos.  
Now I need to replace

- (img: …) with (image: … class: img-medium)
- (imgsmall: …) with (image: … class: img-small)  
etc.

Any help??  
Thanx in advance!

---

<div class="post-metadata">

### Author: ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)
#### Post date: [August 28, 2020, 2:06pm UTC](https://forum.getkirby.com/t/how-to-replace-custom-kirbytags-with-standard-ones/19193/2 "2020-08-28T14:06:38Z")

</div>

You could update the fields in question programmatically, while doing a regex search and replace on each field that may be concerned.

---

<div class="post-metadata">

### Author: ![hvsrmusic](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/hvsrmusic/32/2722_2.png) [@hvsrmusic](https://forum.getkirby.com/u/hvsrmusic)
#### Post date: [August 28, 2020, 2:08pm UTC](https://forum.getkirby.com/t/how-to-replace-custom-kirbytags-with-standard-ones/19193/3 "2020-08-28T14:08:54Z")

</div>

Thank, this is also the solution I came up with. Just wondering if there was something more “elegant”. Thank you.

```
$longs = $pages->find('lungo')->children();

foreach ($longs as $l) 

{

    $t = '';

    $t = Str::replace($l->text(), '(imgsmall:', '(image:');

    $t = Str::replace($t, '(img:', '(image:');

    $t = Str::replace($t, '(yt:', '(video:');

    $t = Str::replace($t, '(ytsmall:', '(video:');

    $t = Str::replace($t, '(video: ', '(video:https://www.youtube.com/embed/');

    $l->update(array(

        'text' => $t)

    );

    echo $l->title() . '<br>';

}
```

---

<div class="post-metadata">

### Author: ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)
#### Post date: [August 28, 2020, 6:45pm UTC](https://forum.getkirby.com/t/how-to-replace-custom-kirbytags-with-standard-ones/19193/4 "2020-08-28T18:45:01Z")

</div>

This could certainly be reduced a bit but since you only have to do it once, it doesn’t really matter.
