VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Studio 42 on January 19, 2018, 15:10:02 PM

Title: Bug fix/feature request External image
Post by: Studio 42 on January 19, 2018, 15:10:02 PM
I needed to support external images for a customer.
This is the fix to solve the issue in front
In file SITEJOOMLA/administrator/components/com_virtuemart/helpers/mediahandler.php
In function displayIt
Search for
if($absUrl){
$root = JURI::root(false);
}

And replace it with
if( substr( $file_url, 0, 4) == "http" ) {
$root = '';
}
else if($absUrl){
$root = JURI::root(false);
}

And you can use external images for thumbs and/or big images.

Not that it dont remove the message, vmError: Couldnt create thumb, file not found ...., if a developper can check about external in Admin, or if you want i can check about this too ? Because i had some user that wanted to use this feature and think that very strange that they cannot use external images.
Title: Re: Bug fix/feature request External image
Post by: Studio 42 on January 19, 2018, 15:31:06 PM
Fix for admin
In file SITEJOOMLA/administrator/components/com_virtuemart/helpers/image.php
After line 141 public function createThumb($width=0,$height=0) {
add
if( substr( $this->file_url_thumb, 0, 4) == "http" ) {
return $this->file_url_thumb;
}

And to fix last error message
In file SITEJOOMLA/administrator/components/com_virtuemart/helpers/mediahandler.php
replace line 508
if(!JFile::exists($toChk)){
With
if(!JFile::exists($toChk) && substr( $this->file_url_thumb, 0, 4) !== "http"){
Title: Re: Bug fix/feature request External image
Post by: melix on January 23, 2018, 22:02:15 PM
Thank you Patrick, I asked myself the same question.
After changes are done, is old system work also with internal urls (auto-resize,etc..) or do we have to add full internal Urls ?( https://mysite/images/etc.)
Or both internal and external urls work if one want to use them or not ???
Title: Re: Bug fix/feature request External image
Post by: Studio 42 on January 24, 2018, 02:51:47 AM
For internal files, it changes nothing because i check for "http" to say to VM, do not try to resize, that's all ;)
of course, if you use external files, you have to set yourself the thumb url(it can be a relative link eg /image/folder/mythumb.jpg or full eg. https://site.com/folder/thumb.jpg).