---
title: "Inte visa bild i citat-funktion (bbkod)"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/179798-inte-visa-bild-i-citat-funktion-bbkod"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Guldstrand"
published: "2009-08-14T19:45:16.000Z"
updated: "2009-08-15T05:13:14.000Z"
replies: 1
views: 365
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/179798-inte-visa-bild-i-citat-funktion-bbkod"
---

# Inte visa bild i citat-funktion (bbkod)

## #1 — Guldstrand, 2009-08-14T19:45Z

Jag använder följande kod till en citat-funktion (bbkod).

```php
function format_quotes($s)
{
  while ($old_s != $s)
  {
  	$old_s = $s;

	  //find first occurrence of [/quote]
	  $close = strpos($s, "[/quote]");
	  if ($close === false)
	  	return $s;

	  //find last [quote] before first [/quote]
	  //note that there is no check for correct syntax
	  $open = _strlastpos(substr($s,0,$close), "[quote");
	  if ($open === false)
	    return $s;

	  $quote = substr($s,$open,$close - $open + 8);

	  //[quote]Text[/quote]
	  $quote = preg_replace(
	    "/\[quote\]\s*((\s|.)+?)\s*\[\/quote\]\s*/i",
	    "<b>Citat:</b><blockquote>\\1</blockquote>", $quote);

	  //[quote=Author]Text[/quote]
	  $quote = preg_replace(
	    "/\[quote=(.+?)\]\s*((\s|.)+?)\s*\[\/quote\]\s*/i",
	    "<b>\\1 skrev:</b><blockquote>\\2</blockquote>", $quote);

	  $s = substr($s,0,$open) . $quote . substr($s,$close + 8);
  }

	return $s;
}
```

Nu skulle jag vilja fixa så att inga bilder syns i citatet, utan endast länken till bilden. Hur löser jag det?

Alltså.. om någon citerar ett inlägg som innehåller en bild, då vill jag automatiskt ta bort \[ img \]\[ /img \] -taggarna, och endast visa länken till bilden i citatet.

Permalänk: https://www.webforum.nu/p/179798

## #2 — Guldstrand, 2009-08-15T05:13Z

\*bump\*

Permalänk: https://www.webforum.nu/p/2198775

---

Tråden på webben: https://www.webforum.nu/amne/php/179798-inte-visa-bild-i-citat-funktion-bbkod
