• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
News content editing with upload images feature

#1
[eluser]SPeed_FANat1c[/eluser]
Hi,

I am trying to make news content editing panel with ability to upload images to server and use them in the article.

I am thinking there should be a form with WYSIWYG editor and ajax image upload. WYSIWYG editor itself does not have image uplaoding feature - you can only insert an image from the url.

So the admin could upload image to the server with ajax and as a response he would see the image url.

I add an extra button to the WYSIWYG editor with function to insert the url which is in some div container.

Btw for me it is interesting how most of the cms do that? It is not confortable for the content editor to uplaod images manualy to some other place, then copy url and the add it to the article. Too many actions.

So I should create images table in database with 3 fields - id, filename and article_id. So by the article id I will be able to delete image records from database in case the article itself is deleted.

So lets say I upload the image with ajax. I need article id, to insert image to the database, but the article is not yet inserted, so there is no article id.

I could insert image with article_id 0. 0 will mean that it is not assigned to any article. Then on article submit I'll have to update those image records with new article_id's. So on ajax upload, I'll have to save somewhere those uploaded picture id's. Then on article submit I have tp update image table recorsd where article_id = 0.

But I don't like my solution very much. And if there is multiple admins, then artile_id of 0 will not be enough. I'll have to think something how to differ those not assigned pictures. Something too complicated. Isn't there a better way to do this?

Edit - just came a thought - there is no problem with that zero value if I save picture id's until article is submitted. On article submit I can seach for those pictures by id and update article_id field. Still - what do you think? Maybe there is better way?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.