qky666 / dokuwiki-plugin-file2dw

Import from file (docx, odt, pdf...) to dokuwiki
MIT License
1 stars 2 forks source link

Filenames to images do not correctly replaced #1

Open mr-floppy opened 5 years ago

mr-floppy commented 5 years ago

https://github.com/qky666/dokuwiki-plugin-file2dw/blob/af0d2a16517888927d65a038be3597d9807dd330/action.php#L355

In line 355 the colon has to be inside the second argument. Otherwise the filename does not get replaced.

- $this->result = str_replace( '{{:'.$imgPath, '{{'.$imgId, $this->result );

+ $this->result = str_replace( '{{'.$imgPath, '{{:'.$imgId, $this->result );
qky666 commented 5 years ago

Hi, I have been testing it again, and it's working. Where do you see the error? Thanks!

mr-floppy commented 5 years ago

I See it in Line 355 of the action.php. $imgPath is always something like "/tmp/myimage.png" $imgId should become something like ":myImage.png"

Line 355 searches for ":/tmp/myImage.png", so it will never replace the string, unless you move the colon as described above.

If it works for you, maybe you still have the images in the /tmp folder or your wiki has another way to find the image, but i doubt it will use the image from the media storage.

The again, dokuwiki says there would be an update 2018-11-29, but all i can find is 2018-11-23. Maybe you are running another version locally and have forgotten to commit it?

Anyway, thanks for your work! I have never heard of pandoc, but it makes so many things so much easier :)

ntoenis commented 5 years ago

I too am experiencing the same issue on the current release and mr-floppy's fix did in fact fix the issues we were seeing

qky666 commented 5 years ago

Hi, Sorry I am late in my answer. I currently have no way to test the change you proposed... So I changed the code and hope it will work (cross fingers). Can you please test it again? You will have to update the plugin, of course. Thanks!

luxusv commented 4 years ago

https://github.com/qky666/dokuwiki-plugin-file2dw/blob/af0d2a16517888927d65a038be3597d9807dd330/action.php#L355

In line 355 the colon has to be inside the second argument. Otherwise the filename does not get replaced.

- $this->result = str_replace( '{{:'.$imgPath, '{{'.$imgId, $this->result );

+ $this->result = str_replace( '{{'.$imgPath, '{{:'.$imgId, $this->result );

I had to add the colon to both arguments:

- $this->result = str_replace( '{{'.$imgPath, '{{:'.$imgId, $this->result );

+ $this->result = str_replace( '{{:'.$imgPath, '{{:'.$imgId, $this->result );
Ackimulator commented 2 years ago

@luxusv Thank you for replying with the "extended" solution :-) just fixed the problem with this information.

Not functional: + $this->result = str_replace( '{{'.$imgPath, '{{'.$imgId, $this->result );

Not functional: + $this->result = str_replace( '{{'.$imgPath, '{{:'.$imgId, $this->result );

Not functional: + $this->result = str_replace( '{{:'.$imgPath, '{{'.$imgId, $this->result );

Functional: + $this->result = str_replace( '{{:'.$imgPath, '{{:'.$imgId, $this->result );

So the ":" has to be in front of the imgPath and in front of the imgld.

@qky666 I suggest updating this (at least the information but if possible the source code) on the DokuWiki Plugin Page so that future users won't run into the same thing first.

I will link this in my regarding DokuWiki forum post (German) and solve the thread. (https://forum.dokuwiki.org/d/19870-file2dw-probleme-mit-txt-odt-und-mit-doc)

Have a nice day everyone :-)