Read image files from non-default directory in PrestaShop 1.6 - image

Hello Stack Overflow community, I have installed PrestaShop 1.6.0.14 in a Xampp server a few weeks ago for the company I work for. They have a web application that handles all the image files from their websites, for example, when a user opens an image with right click->open image in different tab or similar, the url shown is something like:
http://www.example.net/FileViewer/File.aspx?Type=3&File=WebsiteFileDirectory/img/logo.jpg&Width=138&Height=50
As you can see, after the &File= part comes a directory structure and some parameters to handle the image at the end. This directory (WebsiteFileDirectory) is located in C:/StorageFiles/Volume1/, where the web app for image handling looks for file sources.
My PrestaShop /img/ folder needs to be in that location with a directory structure similar to C:/StorageFolder/Volume1/PrestashopFileDirectory/img. So far, I've moved /img/ to that location and managed to make Prestashop write into the new location by editing the constant values _PS_IMG_, _PS_IMG_DIR_ and _PS_CORE_IMG_DIR_ in config/defines.inc.php and config/defines_uri.inc.php
But after that I've hit a brick wall when trying to make PrestaShop read from that location, I've even tried editing the LinkCore::getImageLink() method by hardcoding a uri_path value pointing to the directory mentioned before, with no results whatsoever, PS will try to read from the default location (something like myshop/16-small_default/image_filename.jpg)
How can I make PrestaShop read from that location? Is there even a way to do that?
Thanks in advance.
P.S.: Just to make sure I get a straight forward answer I want to let you know that by now I figured how the image file system in PS 1.6 works, if the image id is 25, PS will store the file in img/p/2/5/ for a product image, I have no problem with anything related to that.

Well, it turns out that getImageLink must be fed a URL (from the image handling webapp I mentioned before), not a filesystem path. So, the uri_path variable in this method would look like:
$uri_path = 'http://www.example.net/FileViewer/File.aspx?Type=3&File='.$my_img_directory.'&Width=138&Height=50';
The methods I have figured so far that need similar tweaking are getMediaLink and getCatImageLink, from the same Link class in the classes/Link.php file.

Related

Magento Image Url "_1.png" added to Image URL

On my website Magento adds _1 to the end of some Image urls.
So my normal basic urls should be ...media/catalog/product/cache/9/A/E/test-small.png
but somehow for some images it alters to ...media/catalog/product/cache/9/A/E/test3-small_1.png
My normal image names are unique numbers so I´m confused why this happens?
Could anyone help?
Magento will add a _1 after any image if the file already exists on the server.
Please mind that Magento is not doing cleaning of the images of products when / if you delete one product.
It is magento's by default feature, if the image name you are trying to upload already exist it will rename your current image name with _Number. Check before uploading.
Thanks
If anyone comes across this post using M2 and is having the same issue. Check out the media/tmp folder. I was working on an api image sync and the name kept having a _1, _2 etc after the image.
It turns out Magento doesn't always give a clear reason if something fails in the api so the file was making it to the tmp directory but never the final destination causing the file name issue.

Forbidden You don't have permission to access /appetitclic/wp-content/themes/Apc/img/logo.png on this server

Hello all :)
I am currently working on a WP website and a the moment I am working locally with Wampserver.
None of my pictures happen to appear on my website.
Here is the error I get when I put the image url in my browser :
Forbidden
You don't have permission to access
/appetitclic/wp-content/themes/Apc/img/logo.png on this server.
I have no problem accessing phpmyadmin and image from TewentyTwelve template work fine.
Things I have tried :
-Editing (and creating) .htaccess in wp-admin.
-Editing phpmyadmin.conf
-Puting Wamp on online mode
-Working through http://127.0.0.1/ instead of locally.
I am pretty sure the problem doesn't have to so with the code because I have access to the /appetitclic/wp-content/themes/Apc/img/ folder and I see the list of images (not working). I maybe missed one or two workarounds but I am pretty sure I tried most of the common ones.
If you need any info on my setup / configs I have tried ask away.
Thank you very much,
Cheers.
If you start your relative url with a backslash '/' that means go to the servers root folder and work up from there.
Try loosing the leading slash and see what that does.
I have that same problem when I downloaded random images for img preloading testing.
So I went to change permission from no access to read & write (if on Mac then > Get info. You shall see that permission section at the very bottom).
You might use chmod to change permission to particular users.
Hope this help.
I had the same problem today. I created a static webpage put in the html folder of my web server. It turned out that some images could not be loaded. The solution is quite simple. I just right click the image folder and changed the properties to allow readers to view the images.

Localhost is no longer working properly

I just built a site using Xampp and it worked great. I just transferred my site (that I used to develop by updating to live server) to localhost, and it isn't working right at all.
The images do not show and the pages are not refreshing properly.
I had to change the CSS images to /folder/x instead of just x, which I can understand I guess, but why are my HTML images suddenly not working?
One of the pages, the paths are even absolute, but the page just isn't updating even though it's saved in the local folder.
What gives? All I did differently was added a password to root user in MySQL and tried (and failed) at some mod_rewrites, which I removed.
It points the images from localhost/ instead of localhost/folder, even adding folder/x doesn't work.
You probably forgot to convert a link or made a mistake.
Remember that /images/x.png means that it's trying to find the folder images from root and not from the current folder your site is located in. Try using ./images/x.png instead.
Perhaps you could post an example from your site?
Try looking at the Apache access logs and see whether you can find a request for an image with the wrong path.

Magento : CMS upload image fail silently

I am trying to figure out why the tinyMCE WYSIWYG editor in the CMS module of Magento will not upload images. I can create/delete folders but any file will simply not get uploaded, and there seems to be no message as to why the file is not successfully written on the server.
Anyone may have an idea why?
** Update **
I'm using Magento 1.6.2. I have tried to track down the problem and it seems that the controller never gets executed. I have added a line to log the arguments in the uploadAction() action (in Mage_Adminhtml_Cms_Wysiwyg_ImagesController) and nothing gets logged.
This is project inherited from someone else, and was modified to some extend, but nothing seems to point out that this part of Magento would have been touched in anyway by the modifications.
** EDIT**
The project associated with this question has been dropped and I no longer can provide an answer to this question. If anyone can confirm a working answer (as this problem was apparantly common with Magento), I will gladly mark that answer as "accepted".
Otherwise, I will flag this question for removal for the aformentioned reasons.
Thank you.
Other than solutions provided here, it may occur when you use a CDN (or a different domain) for your javascript and media files in admin panel. If you use CDN, use it for your website(s) scope and use your own domain for default scope. It will make your website(s) media and javascript files to be loaded from CDN, and backend's media and javascript files to be loaded from your own domain. This will solve your problem.
There are some known issues with flash image uploader on Magento. Unfortunately when it falls, it falls silently. Here are some cases when smth can break it:
if you try to use it with secured connection using open ssl certificate
if you're using it on server with apache authentication
on some Magento versions with prototype 1.7
I think the latter is your best bet. Maybe you should try to apply the patch from here: http://www.magentocommerce.com/boards/viewthread/4348/P45/#t327010
In my case it was a cross domain problem, and one quite hard to find if you ask me...
What was puzzling me was that the uploader for product images was working like a charm but the one in the CMS section was failing completely silently. We are serving the skin folder from an Amazon S3 bucket, and the flash uploader lives under that folder.
Interestingly enough, our version of Magento (1.7.0.2) is using two different methods to calculate the path to the SWF file, depending whether you are under CMS or Product update.
The CMS file (app/design/adminhtml/default/default/template/cms/browser/content/uploader.phtml) is using the following method to embed the Flash Uploader:
<?php echo $this->getSkinUrl('media/uploader.swf') ?>
While the Product image uploader is using:
<?php echo $this->getUploaderUrl('media/uploader.swf') ?>
In our case, the first one resolves to the AWS S3 url, obviously in a separate domain, while the second one will still reference the local domain's url.
So yeah, the quick, dirty fix would be to replace getSkinUrl for getUploaderUrl in app/design/adminhtml/default/default/template/cms/browser/content/uploader.phtml. Alternatively you can extend the core to load a different template in which you would have replaced that method.
I hope this helps somebody... I wish I had found something like this five days ago when I first stumbled upon the issue :-)
Are you using flash uploader with https? If so, is your secure address in differente domain (usually used in shareds ssl)?
I got some trouble with this. I solved by installing a flash uploader disabler plugin.
You can download the plugin with this downloader key:
http://connect20.magentocommerce.com/community/Dull_Uploader
I hope it helps.

Taking over a Joomla created site

So i have a client, who has a disc of an entire site. Root server files, all the way to /httphome/ files...
However, it looks like it was created using Joomla. Now, i know my HTMl and CSS but have never used a CMS like Joomla.
To get this site up and running, am i going to have to install Joomla on my clients server, and then upload the files?
i am going to assume its not that easy.... anyone got any insight into this process and what im looking at?
thanks
Keep in mind that Joomla content resides in a MySql database.
You need the following:
Database export
Create a DB on you MySQL server
Upload the files
Edit configuration.php to work with you db and also set your path there
Also, some components might need some more setup, as some of them have their own cfg files.
To get this site up and running (if the file is really the entire site) should be as simple as setting up a web server and pointing it to the directory with the index in it. Joomla should already be in that file. Let me know if i can elaborate on the process.
Since you are new to Joomla, you might want to try loading the disc contents up on your localhost first. Personally, when I'm trying something new, I hate for my first attempts to be somewhat public - I always feel a little safer if I do the first install someplace local where I'm the only person who can see it.
Best of luck with your project! If you run into any problems, or if you want to confirm that the site is definitely Joomla, let us know and we will get you sorted out.
Do you have the related database? The files that make up Joomla are useless without the database. You could install Joomla and upload your files over the top, but any database changes made by any installed extensions wouldn't be made to that install. You'd also be missing all of the actual site content without the database.
If you do have the database, then all you need to do is import the database in you your mySQL, then upload the files you have on the disc and edit configuration.php file with the new database user and password.

Resources