-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to display images in the view #30
Comments
Posted to your message in the other ticket, but this is probably a better place: The transfer directory shouldn't be used for displaying images--once the upload completes successfully, they should be in your app\webroot\media\static, or app\webroot\media\filter directory (if you are modifying them with filters). Can you post your config for Media? |
The same thing is happening to me. I have been uploading test photos and they are going to app/Media/transfer/img (the plugin will create these directories if they do not exist). However, the code for the view.ctp was provided as... Html->image( '../Media/transfer/img/' . h($employee['User']['basename']), array('alt' => __('Profile Picture'), 'border' => '0')); ?>When I view my page and look at the source code, I can see that the path of the image is pointing to "/cake-directory/img/../Media/transfer/img/filaname.jpg" In my users table in my DB, the file column for the recently created user is "/home/user/public_html/cake-directory/app/Media/transfer/img/filename.jpg" these are clearly not the same address. I would like for my images to rest inside of the webroot, but how do I fix this? |
First I would like to say that I JUST joined github specifically so I could follow this thread so I apologize if there is a certain way of formatting code on here that I'm not aware of... But I think I figured out a if not the solution. I'm on cake 2.2.4 btw. In the Media bootstrap file, change the following... line 107: define('MEDIA_TRANSFER', APP. 'Media' . DS . 'transfer' . DS); line 119: define('MEDIA_URL', 'media/'); use in your view Html->image('../media/transfer/img/' . h($user['User']['basename']), array('alt' => __('title goes here'), 'border' => '0')); ?>The html helper image function automatically looks in "/relative/path/to/cake/App/webroot/img/" so you need the "../" to go up a directory to the webroot where the media directory now lies. |
@bhndbrwneyes The docs are indeed misleading. The recommended method is to use the plugin's MediaHelper instead of the default HtmlHelper. It will automatically find the file's location based on your configuration. To get the uploaded file, use:
to get one the 'filtered' versions, use :
|
Hey bhndbrwneyes, |
Hey gBokiau, When I used your approach, I got an error of Missing Helper |
I just remembered that that was not the only problem I encountered when trying to use the plugin. Initially I got an error when I added the line "require APP . 'Plugin' . DS . 'Media' . DS . 'Config' . DS . 'core.php';" in the app bootstrap. I changed to "require APP . 'Plugin' . DS . 'Media' . DS . 'Config' . DS . 'bootstrap.php';" as I realized the core.php file was missing This was not part of the issue I had raised but I know it might help someone. Thanks all for your time and help |
Hi,
I am trying to use this plugin to upload pictures in a website that am building but am encountering some challenges.
First off when i execute the command "cake Media.Media init", this is what happens
![1](https://camo.githubusercontent.com/b550c8f89d84883586f9e20dc7fa42d30f7013fa1b9eee730467be7eac845ee2/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f333232343135372f38353631392f66396131336236342d363436642d313165322d393630622d6630653839343339666634322e706e67)
The image above shows that the transfer directory is been created outside the webroot directory. When I upload images there been saved in that directory.
Now the problem comes when I try to display, the view does not get the image in the path specified as it tends to check in webroot folder. It does not find the transfer directory and thus displays nothing.
Please help
The text was updated successfully, but these errors were encountered: