/** * function insert_image * Insert the image tag for the given image. Make sure it is present first. * @param string $texcode The TeX code * @param integer $post_id The Post ID * @param integer $commend_id The Comment ID if a comment * @return string The html image tag */ private function insert_image($texcode, $post_id, $comment_id = null, $texcontainer = '%s', $outputcontainer = '%s') { //Set the LaTeX code in its container $texcode = sprintf($texcontainer, $texcode); //Set the group and name for RenderCache $group = 'jLaTeX'; $name = $post_id . '-' . $comment_id . '-' . md5($texcode); //If the image is not in cache, render it if (!RenderCache::has(array($group, $name))) { if ($this->render_image($texcode, $post_id, $comment_id) === false) { return $this->error_format($texcode); } } //Get the url of the image $file_url = RenderCache::get_url(array($group, $name)); //Return the image tag return sprintf($outputcontainer, "<img src=\"{$file_url}\" alt=\"" . trim($texcode) . "\" class=\"jLaTeX\">"); }