Hey
I have some text in a .txt file which using class-textobject (or class-anyfile?) I treat as an image. How do I print the bare contents of this text file?
I tried many functions and only printCustomSizedImage* work, but they don't return bare contents.
I used: `<?php printCustomSizedImage(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL); ?>`
This returns: `This is the content of foo.txt`
I would like pure text returned, nothing else. Is this possible?
Comments
`<?php $txtContents = $_zp_current_image->getContent(); $txtContents = strip_tags($txtContents); echo $txtContents; ?>`
/zp/albums/foo/bar/kitteh
Now how do I get rid of "/zp/albums/foo/bar/"?
`<?php $txtFilename = getUnprotectedImageURL(); $txtFilename = str_replace(WEBPATH.'/'.ALBUMFOLDER.'/'.$_zp_current_album->name.'/','',$txtFilename); $txtFilename = stripSuffix($txtFilename); echo $txtFilename; ?>`
Thank you!
pathinfo returns an array consisting of dirname, basename and extension.
stripsuffix does as the name implies.
To get the txt filename:
`$txtFilename = pathinfo(getUnprotectedImageURL()); $txtFilename = $txtFilename ['basename'];`
To strip the suffix:
`$txtFilename = stripSuffix($txtFilename);`
You could shorten and merge the two:
`$txtFilename = pathinfo(getUnprotectedImageURL()); $txtFilename = stripSuffix($txtFilename ['basename']);`