Page 1 of 1

mosimage adding space to selected gallery image list?

Posted: Sun Jul 17, 2011 5:48 pm
by oestek
I've been running this site for several years, and all of a sudden this problem starts.

Each time I revise a content item and hit apply, a space appears in the the selected content images list (right column in picture above). This throws off the image / mosimage tag alignment and the images do not appear in the published content item. Any idea what's causing this?

Thanks!

Image

Re: mosimage adding space to selected gallery image list?

Posted: Tue Jul 19, 2011 6:57 pm
by bobmail
same exact problem here, out of the blue. version 1.0.x.

anyone?

Re: mosimage adding space to selected gallery image list?

Posted: Thu Jul 21, 2011 3:05 pm
by oestek
Anyone?

Re: mosimage adding space to selected gallery image list?

Posted: Thu Jul 21, 2011 6:47 pm
by bobmail
after much digging i believe i know why. the problem is when a form is submitted, \n in strings is converted to \r\n, at least on windows machines. joomla uses \n as delimiters for image names but when that \r gets in there it screws everything up. so the trick is to remove the \r chars before data is saved to db. it's probably fine in newer versions of joomla, but for now this is what i did and tested it lightly. seems ok. hth

file: administrator/components/com_typedcontent/admin.typedcontent.php

code snippet: (look for the one line of code added below)
[ ... ]
function save( $option, $task ) {
global $database, $my, $mosConfig_offset;

josSpoofCheck();

$nullDate = $database->getNullDate();
$menu = strval( mosGetParam( $_POST, 'menu', 'mainmenu' ) );
$menuid = intval( mosGetParam( $_POST, 'menuid', 0 ) );

$row = new mosContent( $database );
if (!$row->bind( $_POST )) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
// ********** ADD the line below ****************
$row->images=str_replace("\r","",$row->images);
// *******************************************

if ($row->id) {
$row->modified = date( 'Y-m-d H:i:s' );
$row->modified_by = $my->id;
}
[ ... ]

Re: mosimage adding space to selected gallery image list?

Posted: Sat Jul 23, 2011 5:10 pm
by oestek
That looks like a logical solution, but did not work in my case. Each time I referesh, the MOS content gallery list still adds another line. Thanks for the help... any other ideas?

Re: mosimage adding space to selected gallery image list?

Posted: Sat Jul 23, 2011 5:53 pm
by bobmail
sorry to hear, did the job for me. interesting that you mention "refresh". in my case it was "apply" that was causing it and the gap just kept on growing with every itereation. stupid question, but have you tried a different browser? same results?

Re: mosimage adding space to selected gallery image list?

Posted: Sat Jul 23, 2011 6:02 pm
by oestek
You're correct, "apply" is what does it. Sorry for the confusion. Same results all browsers.

Thanks...

Re: mosimage adding space to selected gallery image list?

Posted: Tue Aug 23, 2011 2:36 pm
by oestek
Anyone?

Still having this issue.

Thanks!

Re: mosimage adding space to selected gallery image list?

Posted: Wed Oct 19, 2011 2:44 pm
by gab696
Any solution to this problem ?

Re: mosimage adding space to selected gallery image list?

Posted: Wed Oct 19, 2011 3:43 pm
by oestek
Still having the issue here, the work around is to go into php myadmin and manually delete the extra lines from the content item... it's a pain.

Re: mosimage adding space to selected gallery image list?

Posted: Tue Jan 31, 2012 5:38 pm
by shem_lexluger
Try adding this line into administrator/components/com_content/admin.content.php in function saveContent() before the line if (!$row->check()) {

$row->images = str_replace("\n\r", "", $row->images);

Re: mosimage adding space to selected gallery image list?

Posted: Sat Feb 11, 2012 10:12 am
by johnmendonca
I added the hack above but it didn't fix for me on an existing article with "the problem". :'(
Dug some more and came up with another idea. If the image name is whitespace, don't create the html option. :geek:
Seems to work, my client will be stoked...

Small change surround by comments in file:

includes/joomla.php

Code: Select all

 function GetSavedImages( &$row, $path ) {
                $images2 = array();

                foreach( $row->images as $file ) {
                        $temp = explode( '|', $file );
                        if( strrchr($temp[0], '/') ) {
                                $filename = substr( strrchr($temp[0], '/' ), 1 );

                        //John is making this hack recklessly for mosimage adding space problem
                        } elseif( strlen(trim($temp[0])) == 0) {
                                continue;
                        //end hacking

                        } else {
                                $filename = $temp[0];
                        }
                        $images2[] = mosHTML::makeOption( $file, $filename );
                }

                $javascript     = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \"";
                $imagelist      = mosHTML::selectList( $images2, 'imagelist', 'class="inputbox" size="10" '. $javascript, 'value', 'text' );

                return $imagelist;
        }

Re: mosimage adding space to selected gallery image list?

Posted: Sat Feb 11, 2012 6:43 pm
by oestek
I think that worked! Thanks!

Re: mosimage adding space to selected gallery image list?

Posted: Tue Nov 26, 2013 4:22 pm
by Adam Eterno
Worked for me - many thanks for sharing. The only problem now is that MosImage is (and was before this hack, stuck on a sub-folder). anyone remember where to reset this?

I really don't miss all this faffing around that cames/comes with joomla 1.