rails 3 saving default image while uploading using paperclip - ruby-on-rails-3

i use paperclip to upload images to the server in rails 3. If the user didn't choose any file to upload i want to store a default image in the server i.e., storing a default image in different size like thumb, normal, feature...
:default_url => '/images/:attachment/missing_:style.png'
I already put the above line in the config/initialize folder.
But for my popup slider i use jAlert in that i use js(to read the image from the server) and db(to get the object id) to show the images. So if an id didn't have any image then no folder(thumb, normal,...) are created.
For that reason i want to store default image for id which didn't have image.
My basic need is to make image slider in a popup window.
Thanks,
Arivarasan L

Related

react native - How to insert image to TextInput after uploading immediately

I want to implement a post editing interface works as follow:
user can input text, and when he/she presses the image upload button, after the image is uploaded to the server, the uploaded image need to be inserted after the current cursor, and user can continue to input the text.
How can I achieve this in React Native?
What have you tried so far? It's always better to try and post your current code so that we can help you.
I see two parts to your question
1) Image uploading - You can use a library for picking the image (e.g - https://github.com/react-community/react-native-image-picker). Then when you get the asset url from the image picker library you can use a file upload library (e.g - https://github.com/aroth/react-native-uploader) to upload this to your server and get the stored url back from the server as the response.
2) Image Displaying - For this you can use a native and set its source using the url returned by your server.

phoenix: show image from aws s3

I study the phoenix, create an application that loads the image on aws s3, and then displays it. I was able to upload the image to the cloud, but now it is not clear how to display it to the user on the page (I do not want to make public link to these images in the cloud). I was looking for information on this issue, but did not find anything useful.
From the clouds I get the file as binary data. Do I need to create some of these data is a temporary file that will be displayed on the page? I can display the image as base64, but I think this is not the best way. I would appreciate advice.
Since you've already fetched the image to a binary, you can just send it directly to the client with the appropriate content type and the browser will render it as an image. For example, to fetch and send the png at https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png:
def index(conn, _params) do
image = HTTPoison.get!("https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png").body
conn
|> put_resp_header("content-type", "image/png")
|> send_resp(200, image)
end
If you open this in your browser, you'll see the image being rendered correctly because of the content-type header.

Loading pictures to gallery

I need some advice. In my application people can upload images. I will store the images on a server. I want to make a photo gallery where you can see all uploaded images. Every user has a account. And it will download all uploaded images.
The point is that when you uploaded 1 image it has to download 1 image. But when you upload 10 or more the app will have to download all images and cache the images to your device.
What is the best way to download all images and keep the app running without getting stuck. Also what is the best way to cache all images.
If you want to create some photo gallery apps, check out this open source sample.
Created by Michael Waterfall, which includes photo gallery from images stored on server or locally.
You can modify the code as per your project requirements. And it is easy to handle the images.

Display the actual attached file not as a link in Drupal 6?

I enabled File Upload module in Drupal 6, so if I create a content like Page, I would be able to upload a file like an image or a document. I attached an image in the content and when I viewed it, it shows not the image but the link to it. What would I do to display the actual image? Thanks.
you will get the image path in node-contentType.tpl.php and page.tpl.php. In any of the pages you can display image rather than displaying the image path.

How to upload photos using CakePHP 2.0

I'm developing a simple web app and I just want to allow the user to upload some pictures.
should I just store the picture url on my database table or should I upload the whole picture?
how can I validate the size of the picture being uploaded?
how can I upload the picture from my controller?
thank you all!
I would NOT store the image data in the database. I would create a Behavior that will upload the image to the image directory and store a reference to that image. The behavior can then handle size, mime type, etc. Then add a file upload form to the controller and when the data goes to the model to be saved, it will automatically upload the image and put it where it goes.
If you do not want to build your own, here is a very popular behavior that someone has built.
https://github.com/jrbasso/MeioUpload
Or you could try this simple way of doing it (check the readme.md file) :
https://github.com/malikov/cakephp2.0-image-upload