Search code examples
phpjsonapickeditor

how can make regex or program replace for the following logic


I am using Ckeditor image upload functionality in my admin panel. everything is working fine as per admin panel requirements but in my REST API i need the full url of image file inserted inside ckeditor using ckfinder plugin following format is stored in db

<p><img alt="" src="/food/kcfinder/uploads/images/karunanidhi-759.jpg" style="height:422px; width:759px 

what I try : i used following to replace the $quot;

$product_des = htmlspecialchars_decode(str_replace(""", "\"", $product_des));

but here am facing a problem which is when i replace $quote; it is working fine but i want to replace the src as full path so it will work in my API src="/food/kcfinder/uploads/images/karunanidhi-759.jpg" TO src=www.mydomain/food/kcfinder/uploads/images/karunanidhi-759.jpg is there any way to do this help me out please am stucked

MY API CODE AS PER REQUIRMENT:

$product_des = $records1['description'];
$product_des = htmlspecialchars_decode(str_replace(""", "\"", $product_des));
        $remove[] = "src=";
        $srcfull='src='.$serverimg;
        $product_des =(str_replace($remove, $srcfull, $product_des));
        print_r($product_des);

Solution

  • which version of ck editor you are using? give us more details

    i suggest you to do try in this way

    $remove[] = "'";
    $remove[] = '"';
    $remove[] = "`"; // just as another example
    $res_address = str_replace($remove, "", $description);
    

    you can replace as per your requirement.