Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-06-04 12:21:52

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

candyman wrote:

On my site I have a js.gallery which loads different images called by image ID separated by a comma.

sacripant wrote:

…And I can’t checked multiple checkbox for add multiples images ID to the image field.

As I wrote in the first post this plugin works only with the standard txp behaviour i.e. one article image per article.
It doesen’t work with multiple images.
Maybe in the future I’ll add this capability but this involves a serious rewrite and more code = more page weight so I got to plan it well to keep as small as possible.

.. BTW: bot_show_image should be turned off when you install bot_image_upload or can they live together?

No, they can’t live togheter, bot_image_upload incorporates bot_show_image.

….In your code, you add checkbox after “td:nth-child(9)” but in my table I’m only 7 nth-child.
For the checkbox I need to change the code : iframe.find(“#list td:nth-child(7)”) at line 125.

Are you using a txp version pre 4.8? Again – as I wrote in the first post this plugin is compatible with txp 4.08 +

Last edited by redbot (2010-06-04 14:13:58)

Offline

#14 2010-06-04 13:10:39

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

Version 0.2 is compatible with remora and has some minor fixes

aswihart wrote:

…Noticing that only the most recently uploaded pics will display immediately on the Write tab after being added with the plugin. Other pics are hidden, and it looks like this.

Ok, thank you. This clearly shows there is a problem with the path to the images dir. And this explains also the login problem.
Sadly I can’t understand where the issue is originating. I have installed it in many txp sites (either in local than live) and I can’t experience the problem.
It seems to be the same issue that iam_image_uploader had until version 0.6c but I can’t gather a hint examining its code… mmmh..

Offline

#15 2010-06-04 14:13:04

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

Hey aswihart,
can you test please if this change solves the login problem?

Replace this line (around line 32)

$bot_iframe_url = hu.'textpattern/index.php?event=image';

with this:

$bot_iframe_url = 'index.php?event=image';

Thank you

Offline

#16 2010-06-04 16:12:53

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

As I wrote in the first post this plugin works only with the standard txp behaviour i.e. one article image per article.

Ok, sorry, I’m a bad reader.
By default, checkbox is used for multiple choice, radio for unique choice.

Are you using a txp version pre 4.8? Again – as I wrote in the first post this plugin is compatible with txp 4.08 +

Very strange, it’s a clean install of Txp 4.2.

———————————————
Modif 17h15

In my Txp 4.2,
A tr on textpattern/?event=image image includes 8 td :

0 ID
1 Modify
2 Date
3 Name
4 Thumbnail
5 tags
6 Catégory
7 Checkbox

I don’t understand :(

Last edited by sacripant (2010-06-04 16:31:31)

Offline

#17 2010-06-04 18:50:05

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

sacripant wrote:

…Ok, sorry, I’m a bad reader.

Hey no prob, sorry if I it seemed a harsh answer.

.. By default, checkbox is used for multiple choice, radio for unique choice.

Fair enough. The fact is when I was writing it I was in doubt if it should accept more choiches or not. I’ll see if it’s the case to change it in the next release.

.. 0 ID
1 Modify
2 Date
3 Name
4 Thumbnail
5 tags
6 Catégory
7 Checkbox
I don’t understand :(

Don’t you have an “author” column after ‘category’??
Furthermore the first column is 1, not 0 and, as for the last column, the plugin hides the original checkboxes (column 9) and adds a column with the ones generated by the plugin (column 10).

Last edited by redbot (2010-06-04 18:51:51)

Offline

#18 2010-06-04 19:15:28

aswihart
Member
From: Pittsburgh, PA
Registered: 2006-07-22
Posts: 345
Website

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

redbot wrote:

can you test please if this change solves the login problem?

I haven’t gotten it since updating that line, I will let you know but the login problem seems to be fixed.

Also, not sure if that update affected the thumbnail display issue or not, but it may have helped as I’m having zero issues now if I’m logged in as a Publisher.

The issue persists though if I’m logged in as a “Staff Writer” rather than Publisher and trying to add images uploaded by another user. Is that the way Textpattern works (can’t use other authors’ images in your article)? Either way, the image again displays normally after saving an article that references an image uploaded by another user.

Thanks for the rapid updates!

Last edited by aswihart (2010-06-04 19:21:20)

Offline

#19 2010-06-04 20:11:38

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

Nice plugin redbot, nice indeed :-)

Because I don’t know good contact method to you, redbot, (i suspect your email in your forum profile is a web trap), I will throw this here.

I did small changes to the source, patches I think (goes bit out of the “patch” scope tho). If you like you could look at them redbot.

Download links: Normal plugin file | Compressed

I did remove the help file and such, so that no one starts to credit me of nothing I didn’t create. The downloads are intended to (you) Redbot, not really to public use. They do work tho, and even come with the images that were in the original zip file. I did add following changes:

  • Fixed SQL injections.
  • Moved the CSS to stylesheets (<style> block).
  • Moved Javascript, and CSS, into <head> section.
  • Embedded images to the plugin’s PHP (base64_encoded).
  • Removed escaping from the JavaScript (PHP doesn’t parse invalid variables).
  • Add PHP support for multiple images. It nolonger throws out an error. Tho, I didn’t update the JS to work with multiple images.
  • Checks if the image has thumbnail. If not, shows the full sized image (only PHP).
  • Removed globals that were set in every context.
  • Centralized preference variables.

I did also accidently remove the comments, and indetation changed too. Also the long line are no longer long. Long rows are cut over multiple rows. The theme issues and undefined thumbnail, I didn’t fix.

The thumbnail issue can be fixed by checking if the JS gets anything and if not, change the URL to the full image url. Currently it throws out undefined var notice. Theme support could be improving by hiding everything else than the the form['name="longform"']. Downside is that wildcard searches with find() are slower.

Last edited by Gocom (2010-06-04 20:17:05)

Offline

#20 2010-06-05 11:43:18

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

Don’t you have an “author” column after ‘category’??

I looked, and

If ( "My Txp install" has "only admin author")
   { "TR images table" has "8 TD" (no 'author' column) }
else ("My Txp install" has "more than 1 authors")
   { "TR images table" has "9 TD" ( + 'author' column) }

Offline

#21 2010-06-05 12:50:03

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

Gocom wrote:

I did small changes to the source…

Thank you Jukka that’s great! I really appreciate it!

I need to study some of your your changes carefully as I’m not an expert programmer. Ok, probably I’m not a programmer at all ;) but the suggestions I understood till now are really useful.

One thing I’d like to point out is I noticed you used the new ‘pluggable_ui’. That’s really cool Jukka but the problem is I started to write this plugin for myself and I needed txp 4.0.8 compatibility. That’s also the reason why some of the Jquery selectors are so convoluted at times (4.2 added more ids and classes to the interface). So maybe I should fix the last bugs for the plugin in its actual form for those who need backward compatibility and then start to work on a new version only for 4.2. What do you say? Sounds correct?

Below are my comments after a quick look at your proposed changes and a brief testing

Fixed SQL injections.

Interesting. Two questions: Care to expain exactly what changed and why? I’m really ignorant in matter of security so I’d like to know more. Maybe it has to do with this change:
From

if ($step == 'edit' && $article_id) 

to

if($step == 'edit' && !empty($article_id))

Sadly I can’t understand in what their results may differ :(
Second. Taking for granted that it is always a good thing to write secure code I don’t understand why, in this case, should I care too much. AFAIK one must be logged in to use the plugin, so should I assume a site administrator would want to hack his own site?

Moved the CSS to stylesheets (<style> block).

That’s great. It’s lot tidier (but incompatible with 4.0.8)

Moved Javascript, and CSS, into <head> section.

Same as above

Embedded images to the plugin’s PHP (base64_encoded).

Really cool. However, how you achieved it is a complete mistery to me …I think I need to study it a little more ;)
(strange thing is I can see only the ‘delete’ icon , not the ‘edit’ one – it behaves like it doesen’t exist)

Removed escaping from the JavaScript (PHP doesn’t parse invalid variables).

Hey thanks for the tip! Never thought about it.

Add PHP support for multiple images. It nolonger throws out an error. Tho, I didn’t update the JS to work with multiple images.

Ok – but now thumbnail generation doesn’t seem to work for already saved articles – they show no image at all. Must investigate…

Checks if the image has thumbnail. If not, shows the full sized image (only PHP).

Ok

Removed globals that were set in every context.
Centralized preference variables.

Genius!

P.S. Just out of curiosity, why do you think my email is a ‘web trap’? Should I change it with another one?

aswihart wrote:

The issue persists though if I’m logged in as a “Staff Writer” rather than Publisher and trying to add images uploaded by another user.

Well spotted! I would have never noticed it

Is that the way Textpattern works (can’t use other authors’ images in your article)?

Not quite, it was only marginally a user level issue. I was targeting the thumbnail as a img but a staff writer has only an img because he can’t edit other autors images. Anyway it’s fixed now.

When I’ll have some free time (I hope soon)) I will release the new version wich should fix all the bugs found till now and incorporate some of Jukka’s suggestions while still keeping 4.08 compatibility.
Thank you again for your precious help

sacripant wrote:

…I looked, and ….

Well spotted sacripant! I’ll see if its the case to deal with it in the plugin code or simply mention it in the help and suggest a manual change as you did

Last edited by redbot (2010-06-05 13:06:36)

Offline

#22 2010-06-05 16:28:18

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

Redbot, here’s some answers to your thoughts :-)

redbot wrote:

One thing I’d like to point out is I noticed you used the new ‘pluggable_ui’.

I did not. head_end callback isn’t part of pluggable_ui toolset. Head_end was introduced in 4.0.7. Head_end is also the reason why most of my plugins require 4.0.7 or newer.

Fixed SQL injections. […] Care to expain exactly what changed and why?

I did doSlash() the values used in SQL queries and changed the other to fetch() which gives smaller code footprint.

Sadly I can’t understand in what their results may differ :(

It’s not different. Empty check if the variable is empty (empty meaning zero, false, null etc). I just tend to use it nowdays.

That’s great. It’s lot tidier (but incompatible with 4.0.8)

In compatible with 4.0.8. head_end callback was introduced in 4.0.7.

Ok – but now thumbnail generation doesn’t seem to work for already saved articles – they show no image at all.

I didn’t update the JS. It’s not compatible. And I might have messed something.

P.S. Just out of curiosity, why do you think my email is a ‘web trap’? Should I change it with another one?

Because you are like ninja ;) …and the web prefix. With a trap I mean spam holder, thing that you would use to register accounts and never really use. Heh.

Last edited by Gocom (2010-06-05 17:11:27)

Offline

#23 2010-06-05 17:48:53

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

I’ve been playing around with this interesting plugin, but I’m having problems under Txp 4.0.8:  the Choose image link doesn’t trigger anything when clicked. (All seems to work fine under 4.2.0.)

Suspecting a conflict I turned off all other plugins, but still nothing – any ideas?

Offline

#24 2010-06-05 17:51:30

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_image_upload: upload, sort, edit, show images in ‘write' tab

Gocom wrote:

…I did not. head_end callback isn’t part of pluggable_ui toolset. Head_end was introduced in 4.0.7. Head_end is also the reason why most of my plugins require 4.0.7 or newer.

Doh! That’s really great news. Finally I can have a clean, human readable code, thanks!

I did doSlash() the values used in SQL queries and changed the other to fetch() which gives smaller code footprint.

That’s ok. But – I’m asking again for learning purpose – do you think it is possible to perform SQL injections if you are not logged in to txp?

One last thing. I like your way of embedding images and I’m sure this will come very handy once I learn some more but in this case I’m more inclined to avoid this, so that one can easily replace the default icons. Or I’m missing something again?

That’s all. Thank you again Jukka, you really taught me something useful!

Last edited by redbot (2010-06-05 18:06:03)

Offline

Board footer

Powered by FluxBB