hey i have an issue ive read it once, but i cant find it, when i insert an linkable image it appear at the end of all the text and not where my text pointer were like:

[...]

I think this is the relevant code. In the advanced image module you have this

  MYRTE=window.opener.document.getElementById(area).contentWindow;
  window.opener.currentRTE=area;
  MYRTE.document.body.innerHTML += link1 +\"<img border=\\\"\"+ imageBorder +\"\\\" align=\\\"\"+ imageAlign +\"\\\" alt=\\\"\"+ alternativeText +\"\\\" hspace=\\\"\"+ hSpace +\"\\\" vspace=\\\"\"+ vSpace +\"\\\" src=\\\"".$config_http_script_dir.substr($config_path_image_upload, 1)."/\"+ path +\"\"+ selectedImage +\"\\\">\" + link2;

The image link is just appended to the end of the content in the text area.


The original images.mdu code is a bit different

  MYRTE=window.opener.document.getElementById(area).contentWindow;
  window.opener.currentRTE=area; 
  MYRTE.document.execCommand('InsertImage', false, '-my-temp-img-url-');
  replacement = \"$config_http_script_dir/data/upimages/\" + selectedImage + \"\\\" alt=\\\"\" + alternativeText + \"\\\" border=\\\"\" + imageBorder + \"\\\" align=\\\"\" + imageAlign;
  MYRTE.document.body.innerHTML = MYRTE.document.body.innerHTML.replace(/-my-temp-img-url-/gi,replacement);


Some placeholder text (-my-temp-img-url-) is inserted at the current insertion point. Then this is replaced by the image link.

I haven't tried to edit this and make it work for the advanced. I also wonder what is the purpose of inserting the placeholder text. Why not just construt the image url and then use that in the execCommand statement?

A number of people have asked about sorting the uploaded images by date rather than alphabetically. The solution  I've seen is to replace natcasesort($images_in_dir); with rsort($images_in_dir);. This works for some but not others.  The reason is that readdir() returns filenames in the order in which they are stored by the filesystem, which is not necessarily in chronological order.

My solution

Find:

        $img_dir = opendir($config_path_image_upload);

        $i = 0;

    while ($file = readdir($img_dir))
    {

        $img_name_arr = explode(".",$file);
        $img_type          = end($img_name_arr);
        $img_name = substr($file, 0, -(strlen($img_type)+1));

        if ((in_array($img_type, $allowed_extensions) or in_array(strtolower($img_type), $allowed_extensions)) and $file != ".." and $file != "." and $file != "." and $file != ".htaccess" and $file != "index.html" and is_file($config_path_image_upload."/".$file))

         //Yes we'll store them in array for sorting
         $images_in_dir[] = $file;
    }


Replace with:

// glob files in folder, modify brace to add extensions
$images_in_dir = glob("$config_path_image_upload/*.{jpg,png,gif}",GLOB_BRACE);

//sort by modification date descending
array_multisort( array_map( 'filemtime', $images_in_dir ),SORT_NUMERIC,SORT_DESC,$images_in_dir);

//glob grabs full_path/filename, need to remove path part
foreach ($images_in_dir as &$full_path_name) {
  $full_path_name = basename($full_path_name);
}
unset($full_path_name); // clean up reference


Find and delete:

    natcasesort($images_in_dir);
    reset($images_in_dir);

Edit the {jpg,png,gif} brace to allow the extensions you want. This does not replace the need for the $allowed_extensions variable since that is used elsewhere. You must set both.

This doesn't test whether a name returned is a file or directory, but as long as you don't have directory names with graphic extensions it won't matter.