5

I'm using Aloha editor for editing content on a website powered by PHP and MySQL. It's working fine, but I need to be able to insert images/pictures. I found an Aloha editor plugin for that. Here are some links:

There is an example in the first link. However, I can't get the plugin running on the latest version of Aloha editor and jQuery. It fails to load and Chrome says:

image.js:30 Uncaught TypeError: Cannot read property 'fn' of undefined

I have no bloody clue what this means.

Ideally, the user should be able to select an image from a list of images that are on the server. These are located in a single directory and also have a MySQL table for them. I suspect this is where the repository comes in, but I wasn't able to understand how to implement that.

Has anyone had any luck using this plugin in Aloha editor, or found any other ways of inserting images?

Zdeněk Gromnica
  • 854
  • 2
  • 14
  • 31
  • It says that the first plugin is only tested and built to work in firefox, so you might want to try the one from the second link. Ans you're right about the repository. You just have to implement the method GENTICS.Aloha.Repositories..query = function( p, callback) {vat that = this; ... fill data...callback.call(that, data); } You can find some more information on this wiki page: http://aloha-editor.org/wiki/Repository – csupnig Jun 01 '11 at 07:27
  • 1
    I did, I believe they're all the same plugin. As for the repository, would you have a working example? All I see on the wiki is a concept of what it _should_ be and a huge list of attributes, which isn't really helping. – Zdeněk Gromnica Jun 02 '11 at 09:29
  • Aloha, a good place for questions about Aloha Editor is github. There you'll get answers for technical questions .. https://github.com/alohaeditor/Aloha-Editor/issues – Klaus-M. Schremser Jun 02 '11 at 05:07

2 Answers2

3

A bit too late, but if you need I made a simple plugin for Aloha Editor to insert / upload an image. This plugin is part of my symfony 1.x plugin to easily integrate Aloha in a Symfony app.

This is the source of the Symfony plugin.

And here is my image insert / upload plugin.

It's really simple, and it could probably improved. It doesn't use a file repository on the server side as you expect, so this is only answering to your "any other ways of inserting images" of your question.

j0k
  • 22,600
  • 28
  • 79
  • 90
Michaël Perrin
  • 5,903
  • 5
  • 40
  • 65
  • @PapaDeBeau I set up a live demo and updated the plugin a bit: http://sf1.michaelperrin.fr/test/aloha . More info at http://blog.michaelperrin.fr/2013/02/22/update-of-sfalohaplugin/ – Michaël Perrin Feb 22 '13 at 13:02
  • Thank you so much. The demo is GREAT. I tried Aloha and my issue is getting the "insert image" to show and work. I click on the insert tab and the box doesn't show. I am wondering if it is a setting of sorts? – Papa De Beau Feb 24 '13 at 00:10
0

I wrote this for another editor to post in pictures. Far from perfect but it should work. You should only need to change the .te to your editors iframe

    $SQL = "SELECT * FROM PHOTO_GALLERY";
    $result = mysql_query( $SQL );
    while( $row = mysql_fetch_array( $result ) ) {
    $photo_id = $row["photo_id"];
    $photo = $row["photo"];
    $photo_name = $row["photo_name"];

 $picture = "<img alt='$photo_name' title='$photo_name' src='http://$domain/$photo'>";

echo '<span style="cursor:pointer" class="picture_'.$photo_id.'"><img title="Click to add image" alt="'.$photo_name.'" height="50" src="/'.$photo.'" width="50"/></span>


< script>
 $(document).ready(function(){
$(".picture_'.$photo_id.'").click(function() {
$(".te").contents().find("body").append("'.$picture.'");
});
});
< /script>
MHowey
  • 681
  • 2
  • 6
  • 19
  • I suppose this is as good an answer as I'm going to get. Basically, Aloha doesn't reliably provide image inserting capabilities, so you have to make your own 'toolbar' of sorts that just insert the image. Ugly but functional. – Zdeněk Gromnica May 07 '12 at 14:51