-
AuthorPosts
-
dieudonne Friend
dieudonne
- Join date:
- January 2011
- Posts:
- 947
- Downloads:
- 61
- Uploads:
- 266
- Thanks:
- 452
- Thanked:
- 107 times in 3 posts
August 30, 2011 at 9:16 am #167981Hello,
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=6393 screenshots in attachement :
1-without-pdf-icon.png
2-with-pdf-icon.png
3-the-right-icon-position.pngThank in advance.
One idea would be to add in the code that “Ja Thumbnail” does not include the file named pdf.png
- Sherlock Friend
Sherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
dieudonne Frienddieudonne
- Join date:
- January 2011
- Posts:
- 947
- Downloads:
- 61
- Uploads:
- 266
- Thanks:
- 452
- Thanked:
- 107 times in 3 posts
September 1, 2011 at 10:34 am #410026Thanks 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 Frienddieudonne
- Join date:
- January 2011
- Posts:
- 947
- Downloads:
- 61
- Uploads:
- 266
- Thanks:
- 452
- Thanked:
- 107 times in 3 posts
September 2, 2011 at 2:40 pm #410256Hello,
any idea of this request ?
Sherlock FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
September 5, 2011 at 2:37 am #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]
1 user says Thank You to Sherlock for this useful post
dieudonne Frienddieudonne
- Join date:
- January 2011
- Posts:
- 947
- Downloads:
- 61
- Uploads:
- 266
- Thanks:
- 452
- Thanked:
- 107 times in 3 posts
September 19, 2011 at 1:41 pm #413609Excellent ! 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 Frienddieudonne
- Join date:
- January 2011
- Posts:
- 947
- Downloads:
- 61
- Uploads:
- 266
- Thanks:
- 452
- Thanked:
- 107 times in 3 posts
September 20, 2011 at 8:45 am #413833There is a big problem in the page; the page layout is broken.
I updated the ticket “UHC-690-70577” with 2 screenshot : before & afterThank in advance for your help.
Sherlock FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
September 21, 2011 at 2:26 am #414052Hi 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 !
1 user says Thank You to Sherlock for this useful post
dieudonne Frienddieudonne
- Join date:
- January 2011
- Posts:
- 947
- Downloads:
- 61
- Uploads:
- 266
- Thanks:
- 452
- Thanked:
- 107 times in 3 posts
September 21, 2011 at 7:15 am #414077Excellent.
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 Frienddieudonne
- Join date:
- January 2011
- Posts:
- 947
- Downloads:
- 61
- Uploads:
- 266
- Thanks:
- 452
- Thanked:
- 107 times in 3 posts
September 21, 2011 at 7:29 am #414079Update :
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 Frienddieudonne
- Join date:
- January 2011
- Posts:
- 947
- Downloads:
- 61
- Uploads:
- 266
- Thanks:
- 452
- Thanked:
- 107 times in 3 posts
September 21, 2011 at 8:07 am #414083to 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 FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
September 26, 2011 at 2:30 am #414949Hi 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 !2 users say Thank You to Sherlock for this useful post
AuthorPostsViewing 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
Jump to forum