timmyomahony/django-pagedown

No image upload functionality ?

Closed this issue ยท 21 comments

I don't know if there is a way to upload images using the "insert image" option ?

stackpic

Not at the moment unfortunately. It's something I want to add and there has been a pull request with an approach but I haven't had time to review it or implement it yet.

django-pagedown is very useful for me . Now i need a way to upload image and insert it into my markdown . i have no idea to solved this problem.do you have any solution to solve it ? THX

I gave a pull request for image upload functionality , see that..

iho commented

+1

+1

+1

any way to speed up image upload functionality? Perhaps with a donation in order to buy time for this add-on ? it would be very useful.

Hi @gurugeek I'm going to have a look at adding this. The reason I haven't added it to date is that it's not a part of the editor. I should be able to add it though without hugely affecting the default experience. Maybe it could be enabled as an optional feature via a setting

@timmyomahony thanks a lot. Optional via setting would be fine too. Would be happy to make a small donation if it helps to free some of your time.

I've added this feature now to develop but will need to do some testing before creating a release.

The original PR (2015?) from this thread was very useful but it made a lot of changes to the code, including removing the submodules and hard-coding the pagedown library. Furthermore it relied on an ajax file upload external library as well as jQuery UI.

I've taken this PR and stripped it back to add basic image upload functionality.

image-upload

@timmyomahony thanks a lot for working on this. I will test it too!

A few comments on the handling of the file server-side, I would recommend delegating that job to a django ImageField as shown here:

https://docs.djangoproject.com/en/3.0/ref/forms/fields/#django.forms.ImageField

and here:

https://docs.djangoproject.com/en/3.0/topics/http/file-uploads/

this will add the pillow dependency though, but that is not a particular burden. It will detect file types and deals with many other potential security issues. That being said if the javascript part of the upload works with the current setup we can refactor the Python code and make a pull request as long as you would entertain that idea..

Hi @ialbert, happy to use forms + imagefield + native validation if you have a PR. I don't think the JS would need to change? We'd just need a form that has a file = ImageField(...).

@timmyomahony i am not sure if @ialbert will refactor the code with Python or we currently stick with your recent dev version?

How do I install the develop branch version with pip? Is the pip command the same?

any chance to add some easy instructions for pip install ?

I did manage to install with pip3

ids-MacBook-Pro david_dev_django % pip3 install https://github.com/timmyomahony/django-pagedown/archive/develop.zip
Collecting https://github.com/timmyomahony/django-pagedown/archive/develop.zip
Using cached https://github.com/timmyomahony/django-pagedown/archive/develop.zip
Requirement already satisfied: Django>=2.1 in /usr/local/lib/python3.7/site-packages (from django-pagedown==2.0.3) (3.0.2)
Requirement already satisfied: pytz in /usr/local/lib/python3.7/site-packages (from Django>=2.1->django-pagedown==2.0.3) (2018.9)
Requirement already satisfied: sqlparse>=0.2.2 in /usr/local/lib/python3.7/site-packages (from Django>=2.1->django-pagedown==2.0.3) (0.2.4)
Requirement already satisfied: asgiref~=3.2 in /usr/local/lib/python3.7/site-packages (from Django>=2.1->django-pagedown==2.0.3) (3.2.3)
Building wheels for collected packages: django-pagedown
Building wheel for django-pagedown (setup.py) ... done
Created wheel for django-pagedown: filename=django_pagedown-2.0.3-py3-none-any.whl size=10122 sha256=35f74d4ce8e2f7816c0f232b106ec71ef5de3acf1e72dcecf5c2894c53b5809f
Stored in directory: /private/var/folders/w4/tqwp2zcd3r7_p4nflvl0mkth0000gn/T/pip-ephem-wheel-cache-2cjuyq7g/wheels/1e/0f/ec/fa477da3e48a074a16da13e12ab59ff6cb4afdadbe9e8fcc79
Successfully built django-pagedown
Installing collected packages: django-pagedown
Successfully installed django-pagedown-2.0.3
gurugeek@Davids-MacBook-Pro david_dev_django % python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

but unfortunately it still shows no option for the image upload? :(

It's in the "develop" branch, not the master.
select-develop-branch

I pip installed the develop branch version with this:

pip install -e git+https://github.com/timmyomahony/django-pagedown.git@develop#egg=django-pagedown

Sorry, I haven't had a chance to sit down and review this before pulling it into master so it's still just a feature in develop. I'm going to try get to this ASAP

Hey @timmyomahony Thanks for the feature, much needed!

Is this feature implementation mature enough to be used? I mean I could pull it from the develop branch but I not sure if I can use it in production?

I've modified the image upload functionality to use ImageField now and I've pulled the changes into version 2.1.1. Please try it out and let me know if there are any issues.