test
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • dieudonne Friend
    #167981

    Hello,

    when adding a PDF document with DOCman (and with selecting “insert filetype icon”), the PDF’s icon goes to the Ja Thumbnail.

    Is it possible to disable “Ja Thumbnail Plugin” just for an image (in this case the pdf.png) ?
    Here is the code generated by DOCman :

    <p><a class="doclink" href="index.php?option=com_docman&task=doc_download&gid=3&Itemid="><img src="/components/com_docman/themes/default/images/icons/16x16/pdf.png" alt="icon" border="0" /> analyses 250144 (<span class="small">244.65 kB 2011-08-30 10:52:04</span>)</a></p>

    And the example page :
    http://test.campagnes-cire.be/index.php?option=com_content&view=article&id=455:signez-la-petition&catid=169:campagnes&Itemid=639

    3 screenshots in attachement :
    1-without-pdf-icon.png
    2-with-pdf-icon.png
    3-the-right-icon-position.png

    Thank in advance.

    One idea would be to add in the code that “Ja Thumbnail” does not include the file named pdf.png


    1. 1-without-pdf-icon
    2. 2-with-pdf-icon
    3. 3-the-right-icon-position
    Sherlock Friend
    #410022

    Hi dieudonne,

    you can disable the thumbnail feature for one or more images just using a off tag as below
    {jathumbnail off images=”images/stories/demo/world/us-2.jpg”}

    I hope this make sense !

    dieudonne Friend
    #410026

    Thanks for the tips.
    Yes it’s working.

    But this is always the same image, in this case “pdf.png”.
    So, do you think is it possible to add a code to always stop JA Thumbnail for this image ?

    Thank in advance.

    dieudonne Friend
    #410256

    Hello,

    any idea of this request ?

    Sherlock Friend
    #410634

    <em>@dieudonne 264445 wrote:</em><blockquote>Thanks for the tips.
    Yes it’s working.

    But this is always the same image, in this case “pdf.png”.
    So, do you think is it possible to add a code to always stop JA Thumbnail for this image ?

    Thank in advance.</blockquote>

    Hi dieudone,

    you open the file of pluginscontentplg_jathumbnail.php, look for this function

    [PHP]
    function replaceImage($text, $width, $height) {
    $regex = “/<img[^>]*>/”;
    //Get all images
    if (!preg_match_all ($regex, $text, $matches)) return;
    $images = array();
    foreach ($matches[0] as $image) {
    $regex = ‘#(<img.*)srcs*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (!preg_match ($regex, $image, $srcs)) continue;

    //Check exclude images
    if(!empty($this->_excludeImgs) && in_array($srcs[3], $this->_excludeImgs)) continue;
    //end checked
    if (($src = $this->processImage ($srcs[3], $width, $height, $this->_crop))) {
    $new_image = $srcs[1].”src=”.$srcs[2].$src.$srcs[2].$srcs[4];
    //remove height/width
    $regex = ‘#(<img.*)heights*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (preg_match ($regex, $new_image, $srcs1))
    $new_image = $srcs1[1].$srcs1[4];
    $regex = ‘#(<img.*)widths*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (preg_match ($regex, $new_image, $srcs1))
    $new_image = $srcs1[1].$srcs1[4];
    //$obj = array(‘org’=>$srcs[3], ‘new’=>$src);
    $images[] = array(‘org’=>$image, ‘org_src’=>$srcs[3], ‘new’=>$new_image);
    }
    }
    if (!count($images)) return ”;
    $thumbnail = $this->renderThumbnail ($images, $width, $height);
    return $thumbnail;
    }
    [/PHP]

    change it to

    [PHP]
    function replaceImage($text, $width, $height) {
    $regex = “/<img[^>]*>/”;
    //Get all images
    if (!preg_match_all ($regex, $text, $matches)) return;
    $images = array();
    foreach ($matches[0] as $image) {
    $regex = ‘#(<img.*)srcs*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (!preg_match ($regex, $image, $srcs)) continue;
    if(strpos($srcs[3],”pdf.png”) >= 0) $this->_excludeImgs[] = $srcs[3];
    //Check exclude images
    if(!empty($this->_excludeImgs) && in_array($srcs[3], $this->_excludeImgs)) continue;
    //end checked
    if (($src = $this->processImage ($srcs[3], $width, $height, $this->_crop))) {
    $new_image = $srcs[1].”src=”.$srcs[2].$src.$srcs[2].$srcs[4];
    //remove height/width
    $regex = ‘#(<img.*)heights*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (preg_match ($regex, $new_image, $srcs1))
    $new_image = $srcs1[1].$srcs1[4];
    $regex = ‘#(<img.*)widths*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (preg_match ($regex, $new_image, $srcs1))
    $new_image = $srcs1[1].$srcs1[4];
    //$obj = array(‘org’=>$srcs[3], ‘new’=>$src);
    $images[] = array(‘org’=>$image, ‘org_src’=>$srcs[3], ‘new’=>$new_image);
    }
    }
    if (!count($images)) return ”;
    $thumbnail = $this->renderThumbnail ($images, $width, $height);
    return $thumbnail;
    }

    [/PHP]

    dieudonne Friend
    #413609

    Excellent ! But the page layout is broken …

    And can I add other files like this ?

    if(strpos($srcs[3],"pdf.png","test.jpg",folder.gif") >= 0) $this->_excludeImgs[] = $srcs[3];

    dieudonne Friend
    #413833

    There is a big problem in the page; the page layout is broken.
    I updated the ticket “UHC-690-70577” with 2 screenshot : before & after

    Thank in advance for your help.

    Sherlock Friend
    #414052

    Hi dieudonne,

    There was a little mistake in my codes that caused the problem, this line of code
    [PHP]
    if(strpos($srcs[3],”pdf.png”,”test.jpg”,folder.gif”) >= 0) $this->_excludeImgs[] = $srcs[3];
    [/PHP]

    should be
    [PHP]
    if(strpos($srcs[3],”pdf.png”) && strpos($srcs[3],”pdf.png”) >= 0) $this->_excludeImgs[] = $srcs[3];
    [/PHP]

    I think that would help !

    dieudonne Friend
    #414077

    Excellent.
    It’s working 🙂

    And last question : if I want to put other files, can you tell me if this code is right (I must put 2 times the name of the files ?) ?

    [PHP]if(strpos($srcs[3],”pdf.png”,”home.png”) && strpos($srcs[3],”pdf.png”,”home.png”) >= 0) $this->_excludeImgs[] = $srcs[3];[/PHP]

    I made some tests with this code, and it’s working for pdf.png but not for home.png…..

    Thank in advance for your help.

    dieudonne Friend
    #414079

    Update :

    ok it’s working if I add a new line, like this :
    [PHP] if(strpos($srcs[3],”pdf.png”) && strpos($srcs[3],”pdf.png”) >= 0) $this->_excludeImgs[] = $srcs[3];
    if(strpos($srcs[3],”home.png”) && strpos($srcs[3],”home.png”) >= 0) $this->_excludeImgs[] = $srcs[3];[/PHP]

    But (just for my curiosity), is it possible to make it in 1 line ?

    dieudonne Friend
    #414083

    to summarize :

    in /plugins/content/plg_jathumbnail/, open the file plg_jathumbnail.php. And find this code (line 284-316) :
    [PHP] function replaceImage($text, $width, $height)
    {
    $regex = “/<img[^>]*>/”;
    //Get all imagesn
    if (!preg_match_all($regex, $text, $matches))
    return;
    $images = array();
    foreach ($matches[0] as $image) {
    $regex = ‘#(<img.*)srcs*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (!preg_match($regex, $image, $srcs))
    continue;
    //Check exclude images
    if (!empty($this->_excludeImgs) && in_array($srcs[3], $this->_excludeImgs))
    continue;
    //end checked
    if (($src = $this->processImage($srcs[3], $width, $height, $this->_crop))) {
    $new_image = $srcs[1] . “src=” . $srcs[2] . $src . $srcs[2] . $srcs[4];
    //remove height/width
    $regex = ‘#(<img.*)heights*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (preg_match($regex, $new_image, $srcs1))
    $new_image = $srcs1[1] . $srcs1[4];
    $regex = ‘#(<img.*)widths*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (preg_match($regex, $new_image, $srcs1))
    $new_image = $srcs1[1] . $srcs1[4];
    //$obj = array(‘org’=>$srcs[3], ‘new’=>$src);
    $images[] = array(‘org’ => $image, ‘org_src’ => $srcs[3], ‘new’ => $new_image);
    }
    }
    if (!count($images))
    return ”;
    $thumbnail = $this->renderThumbnail($images, $width, $height);
    return $thumbnail;
    }[/PHP]

    Change it to :
    [PHP] function replaceImage($text, $width, $height)
    {
    $regex = “/<img[^>]*>/”;
    //Get all images
    if (!preg_match_all ($regex, $text, $matches)) return;
    $images = array();
    foreach ($matches[0] as $image) {
    $regex = ‘#(<img.*)srcs*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (!preg_match ($regex, $image, $srcs)) continue;
    if(strpos($srcs[3],”pdf.png”) && strpos($srcs[3],”pdf.png”) >= 0) $this->_excludeImgs[] = $srcs[3];
    //Check exclude images
    if(!empty($this->_excludeImgs) && in_array($srcs[3], $this->_excludeImgs)) continue;
    //end checked
    if (($src = $this->processImage ($srcs[3], $width, $height, $this->_crop))) {
    $new_image = $srcs[1].”src=”.$srcs[2].$src.$srcs[2].$srcs[4];
    //remove height/width
    $regex = ‘#(<img.*)heights*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (preg_match ($regex, $new_image, $srcs1))
    $new_image = $srcs1[1].$srcs1[4];
    $regex = ‘#(<img.*)widths*=s*([“‘])(.*?)2(.*/?>)#im’;
    if (preg_match ($regex, $new_image, $srcs1))
    $new_image = $srcs1[1].$srcs1[4];
    //$obj = array(‘org’=>$srcs[3], ‘new’=>$src);
    $images[] = array(‘org’=>$image, ‘org_src’=>$srcs[3], ‘new’=>$new_image);
    }
    }
    if (!count($images)) return ”;
    $thumbnail = $this->renderThumbnail ($images, $width, $height);
    return $thumbnail;
    }[/PHP]

    If you want to add a other file, just add a new line like this :
    [PHP]if(strpos($srcs[3],”new-file.png”) && strpos($srcs[3],”new-file.png”) >= 0) $this->_excludeImgs[] = $srcs[3];[/PHP]

    Thank to Dat Hoang for the tip !

    Sherlock Friend
    #414949

    Hi dieudonne,

    You can just add a line of code like this
    [PHP]
    if(preg_match(‘/(.*?)(pdf.png|home.png)/’,$srcs[3])) $this->_excludeImgs[] = $srcs[3];
    [/PHP]

    you separate the name of image file by a |
    I think this would help !

    dieudonne Friend
    #414983

    Excellent.

    Thank you very much for your help.
    It’s working great 🙂

Viewing 13 posts - 1 through 13 (of 13 total)

This topic contains 13 replies, has 2 voices, and was last updated by  dieudonne 13 years, 3 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum