Why Images are not attached in test spec (MS Word formnat)?

LATEST Official version.
Questions and discussions - NO ISSUES
FOR ISSUES => http://mantis.testlink.org

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
aostad
Member of TestLink Community
Posts: 183
Joined: Wed Apr 01, 2009 8:32 pm

Why Images are not attached in test spec (MS Word formnat)?

Post by aostad »

I have noticed no images are attached to test report or test spec documents, if they are generated in MS Word format. It works just fine in HTML format.
If it is a configuration issue, please provide steps to fix it.
Any help is much appreciated.
istream
Advanced user
Posts: 59
Joined: Wed Mar 31, 2010 10:28 pm

Re: Why Images are not attached in test spec (MS Word formna

Post by istream »

Hi,
Please see following in the documentation, I got it working for me, following instruction in section 5.7.4.
Cheers.
========================================================
5.7.4. CKEditor custom configuration
CKEditor could be configured via settings in file: <testlink>/cfg/tl_fckeditor_config.js.
This file include toolbar definitions and options as described in the editor documentation: FCKeditor 2.x/Developers Guide/Configuration/Configuration Options
Paste from Open Office or other document editors
Consider the next option for default behaviour:
FCKConfig.ForcePasteAsPlainText = true ;
FCKConfig.AutoDetectPasteFromWord = true;
===============================================
aostad
Member of TestLink Community
Posts: 183
Joined: Wed Apr 01, 2009 8:32 pm

Re: Why Images are not attached in test spec (MS Word formna

Post by aostad »

Thanks for quick reply.
My problem is not attaching an image to a test case. The problem is that the generated test spec/report/plan documents do not have any of corresponding uploaded images, if the generated document is in MS Word format. The places that an image supposed to be (e.g. in summery of a test case) is blank with an error messaeg that says:
"The linked image cannot be displayed. The file may have been moved, renamed, or deleted. Verify that the link points to the correct file and location."

Uploading image by CKEditor is done and it can be displayed in HTML format of a generated document (e.g. Test Plan), but the image does not get downloaded and attached to the document, if it is in MS Word format.
waver
TestLink user
Posts: 4
Joined: Thu Dec 16, 2010 6:46 pm

Re: Why Images are not attached in test spec (MS Word formna

Post by waver »

Hi aostad,

I had tha same issue. I figured out that the problem is the path to the image (src="/path/to/image.jpg").
If it is (src="http://www.example.com/path/to/image.jpg") it is working in some Word Versions.
Following code snippet is able to add the domain name in front of images:

Code: Select all

####################################################################################
# change relative image paths to absolute image paths
# src="/  => src="http(s)://example.com/
####################################################################################

# fetch protocol and domainname
if($_SERVER["SERVER_PORT"]=='443'){
	$url_host = "https://".$_SERVER["HTTP_HOST"];
}elseif($_SERVER["SERVER_PORT"]=='80'){
	$url_host = "http://".$_SERVER["HTTP_HOST"];
}else{
	$url_host = $_SERVER["HTTP_HOST"].":".$_SERVER["SERVER_PORT"];
}
if(substr($url_host, -1)!='/'){
	$url_host.= '/';
}

$xPattern = "/src=\"\//si";
$xValue = "src=\"".$url_host;
$docText = preg_replace($xPattern, $xValue, $docText);
####################################################################################
just paste this code snippet on line 292 in /TestLink_1.9.1/lib/results/printDocument.php
Hope it works on your Word version.

I know this solution is "quick and dirty" usually a new method / function should be added to /TestLink_1.9.1/lib/functions/print.inc.php and on line 292 of /TestLink_1.9.1/lib/results/printDocument.php this function should called. But this is also working and easier to add in to a new version. May be this poblem is going to be fixed in a future version.

Regards waver
aostad
Member of TestLink Community
Posts: 183
Joined: Wed Apr 01, 2009 8:32 pm

Re: Why Images are not attached in test spec (MS Word formna

Post by aostad »

Thanks a lot. You saved me a lot of time for copy/paste images.
I believe it is a bug and need to be looked at.

Cheers,
AO
waver
TestLink user
Posts: 4
Joined: Thu Dec 16, 2010 6:46 pm

Re: Why Images are not attached in test spec (MS Word formna

Post by waver »

Which Version of Word are you using?
My Findings are:
- Word 2003 SP3 (Windows XP SP3) -> working fine
- Word 2004 (OSX 10.6) -> working very slow (until the image is in the visible area it start to load it 50kb - 1-2 min)
- Word 2008 (OSX 10.6) -> working very slow

Regards Waver
aostad
Member of TestLink Community
Posts: 183
Joined: Wed Apr 01, 2009 8:32 pm

Re: Why Images are not attached in test spec (MS Word formna

Post by aostad »

I use Office 2007. It's pretty good and have not noticed any issue.
sss
Advanced user
Posts: 17
Joined: Fri Feb 26, 2010 9:48 am

Re: Why Images are not attached in test spec (MS Word formna

Post by sss »

Hi aostad,

Will this solution work for 1.8.5 ? We are using Word 2002 and facing similar issue?

thanks for help.
waver
TestLink user
Posts: 4
Joined: Thu Dec 16, 2010 6:46 pm

Re: Why Images are not attached in test spec (MS Word formna

Post by waver »

Hi sss,

it should work, but you have to replace $docText with $generatedText and insert it on line 249.
Before 250 $generatedText .= renderEof();

I've not tested on 1.8.5. please report if it is working.

Regards waver
sss
Advanced user
Posts: 17
Joined: Fri Feb 26, 2010 9:48 am

Re: Why Images are not attached in test spec (MS Word formna

Post by sss »

Thanks waver. After modifying as per your suggestion it is working fine.

Thanks again.

Regards,
sss
waver
TestLink user
Posts: 4
Joined: Thu Dec 16, 2010 6:46 pm

Re: Why Images are not attached in test spec (MS Word formna

Post by waver »

To prevent this issue FCKedit php connector configuration can be changed like this: http://mantis.testlink.org/view.php?id=4396
abbey4u
TestLink user
Posts: 8
Joined: Fri Jan 07, 2011 11:22 am

Re: Why Images are not attached in test spec (MS Word formna

Post by abbey4u »

I tried changing the fckeditor config but wasn't successfull .
While generating test plan report in word format, the company logo is missing. I tried giving absolute path but still a problem
Can some one help please

$output .= '<p style="text-align: center;"><img alt="TestLink logo" ' .
'title="configure using $tlCfg->document_generator->company_logo" height="53" '.
' src="https://server:88/testlink/s1/gui/theme ... ges/c1.png" />';

$output .= '<p style="text-align: left;"><img alt="TestLink logo" ' .
'title="configure using $tlCfg->document_generator->company_logo" height="900" '.
' src="' . $_SESSION['basehref'] . TL_THEME_IMG_DIR . 'c1.png' . '" />';
Post Reply