Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-02-16 11:25:16

Bastian
Plugin Author
From: Wuppertal, Germany
Registered: 2005-02-02
Posts: 376
Website

Img Selector - a very little hack

For v0.2 look here

I know: 99% of this site’s vistors are able to type in img-tags on there own. But at least 50% of the guys, that write with txp can’t. One of these 50% is my customer.

So I wrote an Image Selector. This puts out a list of all uploaded images and inserts an images per klick into the post. width, height, alt-text and float are inserted to.

Step 1:
Download <a href=‘http://samisdat.org/files/bas_img.php.txt’>this file</a>, rename it to bas_img.php an upload it to /textpattern/lib/

Step 2
Open /textpattern/include/txp_article.php an search for
<pre>//— textile help ———————</pre>

Some lines below – around 380 – insert after

<pre>if ($view==‘text’) { </pre>

the line

<pre>
echo “<p><a href=‘lib/bas_img.php’ target=’_blank’>Insert image</a>”;
</pre>

That’s all.

The image-selector is not a beauty-queen, but on my site and local it works. I tested it width IE 6.0, Firefox 1.0 and Opera 7.5.

Last edited by Bastian (2005-03-12 14:15:41)

Offline

#2 2005-02-16 18:09:25

ChrisJ
Member
From: Vienna, Austria
Registered: 2004-03-30
Posts: 54
Website

Re: Img Selector - a very little hack

Pretty cool. One request: could it also support thumbnails?

BTW, change Bild einf&#252;gen to Insert image

Offline

#3 2005-02-16 19:24:36

Bastian
Plugin Author
From: Wuppertal, Germany
Registered: 2005-02-02
Posts: 376
Website

Re: Img Selector - a very little hack

Your are right! Bild is German, image ist English. I changed it :)
I do my very best, to write in English.

The txp_images only saves for each img only thumbnails true or not.
So i forget the thumbnails.

But sure, it sould support thumbnails.

I think it is not a big problem, to do so: For each img with thumb true it has to get the thumbnail.

Maybe after the weekend.

Last edited by Bastian (2005-02-16 19:25:16)

Offline

#4 2005-02-16 20:37:54

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: Img Selector - a very little hack

Great idea. Well done & thanks. If you get round to thumbs even better.

Offline

#5 2005-03-02 11:24:31

lithiumdave
Member
From: UK
Registered: 2004-09-14
Posts: 10

Re: Img Selector - a very little hack

Did you get round to the thumbs Bastian? Great little plugin!

Offline

#6 2005-03-03 23:01:29

feragnoli
Member
From: the hague
Registered: 2005-02-10
Posts: 150

Re: Img Selector - a very little hack

hello bastian,

first of all, thank you very much for this plugin, it’s something Txp really needs.

I have my textpattern folder in a sub-folder of my directory like: my_url.com/sub_folder.
when I load your plugin page it’s ok.
except: he doesn’t show any image because he displays its real name (not the id in the database), he is able to place the right image in the article tag (that means I have to know exactly the name of the image because I cannot see it).

then another problem is that using any of your drop-down menusmakes my browser load your plugin which it cannot find since he misses the sub-folder name in the path (this might be something wrong in my confi.php file..?).
he tells me:

<b>The requested URL /textpattern/lib/bas_img.php was not found on this server.</b>

he should look for:

<b> URL /1646/textpattern/lib/bas_img.php </b>

if you could see any sense in this, it would be fantastic.
one more thing: wouldn’t be possible to just have a drop-down menu with the image names in the article page instead of a link to a new page?


what was that again…?

Offline

#7 2005-03-03 23:25:28

feragnoli
Member
From: the hague
Registered: 2005-02-10
Posts: 150

Re: Img Selector - a very little hack

bas, I also have found that inserting the fuller path in your php file, for instance on line 3:

$file = ‘<b>/1646</b>/textpattern/lib/bas_img.php’;

in place of:

$file = ‘/textpattern/lib/bas_img.php’;

and so on all the way, well, this fixes the problem of the drop-down menus.

also, I found out that clicking on the image gives no result in safari and only works in opera!

thanks


what was that again…?

Offline

#8 2005-03-04 00:18:32

feragnoli
Member
From: the hague
Registered: 2005-02-10
Posts: 150

Re: Img Selector - a very little hack

bastian, I see the problem is that the javascript does NOT fetch the proper path.
in the source of the page rendered by the server it gives:

< a >< b >camera.jpg</ b >< li >< a href=‘javascript:insert_img(“images/16.jpg”,“280”,“210”,”“,“0”)’><b>< img src=“images/16.jpg” width=“280” height=“210” alt=”“ /></b>< /a >

the <b>bold < img src ></b> which should link the source image is set to the same path which will be pasted in the body of the article while at the moment I am selecting the images I find myself in the subfolder <b>/textpattern/lib</b>.

also in the final html he echoes a path with a slash in front like: “<b>/<b>images/an_image.jpg”.

ciao

Last edited by feragnoli (2005-03-04 00:21:08)


what was that again…?

Offline

#9 2005-03-04 07:40:26

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,101
Website GitHub Mastodon Twitter

Re: Img Selector - a very little hack

It works well for me. Is there a way for the image tag to be inserted in the Article Image field?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#10 2005-03-06 17:32:11

Bastian
Plugin Author
From: Wuppertal, Germany
Registered: 2005-02-02
Posts: 376
Website

Re: Img Selector - a very little hack

I#m just back home, last week i had a little vacation.
(No Handy, no Internet, just books – not even a notebook. Nice)

But this evening I start to debug.

@colak: Yes there is a way, to put the image list into the Article Image field. I did that one at work.
Next time I’m there at Wednesday and I will load it up.
But I think, it might be confusing, since you have more then a couple of images.
There should be a image category selection, too.

Last edited by Bastian (2005-03-06 17:32:45)

Offline

#11 2005-03-12 14:12:36

Bastian
Plugin Author
From: Wuppertal, Germany
Registered: 2005-02-02
Posts: 376
Website

Re: Img Selector - a very little hack

I finished v0.2.

You can now select the images form a dropdown-list in the write-screen or in a popup-window.

To enable the img selector there are three steps to do:

Step 1
Download this file, rename it to bas_img.php an upload it to /textpattern/lib/

Step 2

Open /textpattern/include/txp_article.php and add after the copyright comment:

include(“lib/bas_img.php”);

Step 3

Search in /textpattern/include/txp_article.php an search for

//— textile help ———————

Some lines below – around 380 – insert after

if ($view==‘text’) {

the line

bas_img_selection();

That’s all.

You can edit the first lines of bas_img.php to make shure, that it fits to your needs. I hope, that my comments there are helpfull :)

Last edited by Bastian (2005-03-12 14:14:23)

Offline

#12 2005-03-12 16:43:52

webicus
New Member
From: Wuppertal, Germany
Registered: 2004-02-24
Posts: 7

Re: Img Selector - a very little hack

Thanks for adding this missing piece, neighbour.

Offline

Board footer

Powered by FluxBB