ashok

ashok

I want to create image upload just like Facebook profile image or what’s app profile image to show image upload progress and resize image to fit into thumbnail image. Store image URL in db.

Please suggest how to to?

Showing Posts 1 to 10

OvermindDL1

OvermindDL1

Well on the backend side it’s fairly easy there, things like the Waffle library and so forth simplify more of the work. As for the front-end, that’s well beyond phoenix’s scope and is generally determined based on what framework that you are already using there?

ashok

ashok OP

What is the link of Waffle library and how to add it in Phoenix?. Is Phoenix have any inbuilt image upload plugin. Please suggest?

Rainer

Rainer

I’m using mogrify / ImageMagick for imageprocessing in the backend, but no ajax frontend (wanna use phoenix liveview later)

hauleth

hauleth

You want to display image editor similar to the FB one? Or you want to resize image after the upload?

ashok

ashok OP

I have a page where I have user’s email , name and his profile pic and there would be a pencil icon for edit. Once user will click on pencil icon I want to change user his profile pic and his name or email.

In my layout there is no submit button which use will click after editing all, so want to know how to achieve it. I am assuming that I have to use Ajax call to update profile image, name or email …

Is there any tutorial which help me to achieve it?

ashok

ashok OP

In the documentation URL: File Uploads – Phoenix v1.3.0-rc.1

I have found that for image upload I have to use a form with multipart form data enabled but when I use the form it shows me error as shown below:

[error] #PID<0.666.0> running MyAppWeb.Endpoint (connection #PID<0.665.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /playgame
** (exit) an exception was raised:
    ** (ArgumentError) assign @changeset not available in eex template.

Please make sure all proper assigns have been set. If this
is a child template, ensure assigns are given explicitly by
the parent template as they are not automatically forwarded.

Available assigns: [:conn, :current_user, :user_token, :view_module, :view_template]
tenzil

tenzil

waffle looks more like carrierwave, ror devs may find it easy

evomedia247

evomedia247

https://cloudinary.com/ is great for this and has a heafty free usage, simply upload the image and call the api with dimensions to return an image of desired size.Not a code solution but worth a look

josefrichter

josefrichter

I have fresh experience with this topic, and it’s incredibly easy to implement with services like Uploadcare, Cloudinary, and a few others.

Here is all I needed to do:

  1. include Uploadcare js library and a hidden input tag into my form
<input type="hidden" role="uploadcare-uploader" name="post[image_url]" data-image-shrink="1024x1024" />
  1. add image_url string field to Post struct, adjust changeset cast
  2. obviously add <img src=<%= @post.image_url %>/> to show template

That’s it!

Basically the js will show Upload button, show full upload interface with drop area etc., possibly also cropping before upload, then performs the Ajax upload and just puts the hosted image url into your form, so that you can submit it and save it in db.

Full blown image upload solution, including client side resizing before upload (that’s the data-image-shrink attribute), and obviously all the other goodies like delivery of image in multiple sizes, cropping on delivery, applying effects, etc. etc.

It does cost money. But the solution is so easy and elegant, no fiddling with imagemagick, s3 and whatnot, which feels like prehistoric approach. I love it now. I though it might be worth sharing.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews