OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



HTML Thumbnail Images problem

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

HTML Thumbnail Images problem

Postby soj » Mon Nov 13, 2006 10:28 am

Hi, in our most recent publication, the system successfully renamed uploaded images, both images files and within the HTML galley file. However, images calling other images (thumbnails) were not apparently renamed in the HTML galley:

<a href="fig1.jpg" target="_blank"><img src="fig1thumb.jpg" />

was converted to:

<a href="fig1.jpg" target="_blank"><img src="http://pathremovedforthis post/11/12/111" />

What's the best approach to fixing this?

TIA! Soj
soj
 
Posts: 151
Joined: Fri Oct 28, 2005 1:53 pm
Location: Norman OK USA

Postby asmecher » Mon Nov 13, 2006 10:48 am

Hi Soj,

OJS doesn't currently support linking to HTML images like you're trying to do, but adding support should be straight forward. Try the following modification.

Edit classes/article/ArticleHTMLGalley.inc.php and find:
Code: Select all
foreach ($images as $image) {
    $imageUrl = Request::url(null, 'article', 'viewFile', array($this->getArticleId(), $this->getGalleyId(), $image->getFileId()));
    $contents = preg_replace(
        '/[Ss][Rr][Cc]\s*=\s*"([^"]*' . preg_quote($image->getOriginalFileName()) .    ')"/',
        'src="' . $imageUrl . '"',
        $contents,
        1
    );
}
Change this block of code to:
Code: Select all
foreach ($images as $image) {
    $imageUrl = Request::url(null, 'article', 'viewFile', array($this->getArticleId(), $this->getGalleyId(), $image->getFileId()));
    $contents = preg_replace(
        '/[Ss][Rr][Cc]\s*=\s*"([^"]*' . preg_quote($image->getOriginalFileName()) .    ')"/',
        'src="' . $imageUrl . '"',
        $contents,
        1
    );
    $contents = preg_replace(
        '/[Hh][Rr][Ee][Ff]\s*=\s*"([^"]*' . preg_quote($image->getOriginalFileName()) .    ')"/',
        'href="' . $imageUrl . '"',
        $contents,
        1
    );
}


(Note: Code fixed per comment below.)

Please confirm whether this does what you need, and if so, we'll consider it (or equivalent cleaner code) for inclusion in the next release.

Regards,
Alec Smecher
Open Journal Systems Team
Last edited by asmecher on Mon Nov 13, 2006 3:07 pm, edited 2 times in total.
asmecher
 
Posts: 9050
Joined: Wed Aug 10, 2005 12:56 pm

Almost there

Postby soj » Mon Nov 13, 2006 1:01 pm

Wow, thanks for the quick response! I modified the file as requested and reloaded the HTML galley. The image file name was successfully replaced, however, the "href" portion of the tag was omitted by the system. Source output reads as follows:

Code: Select all
<a src="http://pathremoved/viewFile/11/12/112" target="_blank"><img src="http://pathremoved/viewFile/11/12/111" />


soj
soj
 
Posts: 151
Joined: Fri Oct 28, 2005 1:53 pm
Location: Norman OK USA

Postby soj » Mon Nov 13, 2006 2:16 pm

I believe I repaired the suggested code modification by substituting href= for the second instance of src=. The following replacement code is working for us:


Code: Select all
foreach ($images as $image) {
    $imageUrl = Request::url(null, 'article', 'viewFile', array($this->getArticleId(), $this->getGalleyId(), $image->getFileId()));
    $contents = preg_replace(
        '/[Ss][Rr][Cc]\s*=\s*"([^"]*' . preg_quote($image->getOriginalFileName()) .    ')"/',
        'src="' . $imageUrl . '"',
        $contents,
        1
    );
    $contents = preg_replace(
        '/[Hh][Rr][Ee][Ff]\s*=\s*"([^"]*' . preg_quote($image->getOriginalFileName()) .    ')"/',
        'href="' . $imageUrl . '"',
        $contents,
        1
    );
}


Cheers! Elke
soj
 
Posts: 151
Joined: Fri Oct 28, 2005 1:53 pm
Location: Norman OK USA

Postby asmecher » Mon Nov 13, 2006 3:07 pm

Hi Soj,

Yes, thanks for catching that typo -- I've fixed it in the original quote in case someone else wants to use it. I'll file a bugzilla entry and this may be included in the next release.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 9050
Joined: Wed Aug 10, 2005 12:56 pm

Postby soj » Mon Nov 13, 2006 3:33 pm

Great - TUVM! soj
soj
 
Posts: 151
Joined: Fri Oct 28, 2005 1:53 pm
Location: Norman OK USA


Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot] and 7 guests