News:

Looking for documentation? Take a look on our wiki

Main Menu

Bug fix/feature request External image

Started by Studio 42, January 19, 2018, 15:10:02 PM

Previous topic - Next topic

Studio 42

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.

Studio 42

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"){

melix

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 ???

Studio 42

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).