WordPress.org

Support

Support » Plugins and Hacks » BMo Expo - a WordPress and NextGEN Gallery plugin » [Resolved] Filepath to Images Not Correct

[Resolved] Filepath to Images Not Correct

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Benedikt Mo

    @bmodesign2

    hm… maybe a xampp problem.

    Do you run xampp on windows or mac?

    Here the same problem. I’m running xampp on windows.

    How can i solve the problem?
    Fred

    I’m running xampp on widows as well.

    I’ll just try on a live site then. But if you figure something out I’d be happy to read it here.

    hi all,

    I am using windows operating system as host and I have noticed the same problem in both BMo Expo and Nextgen ScrollGallery plugins.
    I think the problem comes from metadata info about images. In my case, they come from NextGen Gallery.
    Yesterday, I wrote an routine to strip ABSPATH info from $picture->path and the Nextgen ScrollGallery plugin is working as expected. Even the “divide by zero” error was gone. I consider I am in beta version and tomorrow after more tests I will have a final version to send to Benedikt Mo as a suggestion.

    @benedikt Mo

    I made a routine to fix filepath to images as SpillnerDesign said.
    I have tested it with the version 1.8.2 of Nextgen ScrollGallery, but I believe it fix BMo Expo plugin in the same way.
    I hope you would like this routine.
    Thanks,
    Miguel
    side note: this is not related to “divide by zero” error.

    // mlsp
    /* the problem
     * I have noticed that scrollgallery create links to images using the following code
     *	SCROLLGALLERY_SITEBASE_URL . "/" . $picture->path ."/" . $picture->file
     * This works in almost all unix environments, but, in windows, $picture->path has the absolute fullpath to the image file and the link become invalid.
     * Like that: http://mysite.org/wordpress/E:/Home/httpdocs/wordpress/wp-content/gallery/2013/dsc_3823.jpg
     *
    /* the goal
     *In the example above, E:/Home/httpdocs/wordpress/wp-content/gallery/2013 is the $picture->path and needs to be adjusted.
     *My goal is to remove the absolute fullpath part from the result of $picture->path.
     *
    /* the strategy
     *	I have noticed the part I want to remove is the absolute full path to site I know as ABSPATH.
     *	Then I made a routine named nggSGStartPath that remove the ABSPATH from $picture->path and inserted the code
     *		$picture->path = nggSGStartPath(SCROLLGALLERY_SITEBASE_HOMEPATH,$picture->path);
     *	at the right place.
     *
     *	There is one caveat, I mean, ABSPATH is like E:\Home\httpdocs\wordpress/ (note the first and the last slash) and $picture->path is like E:/Home/httpdocs/wordpress/wp-content/gallery/2013.
     *	I have to deal with it.
     *	We believe this routine does not break unix hosted systems.
     */
    
    //mlsp
    //this routine removes the start of a full path as e:\folder1\folder2 becomes \folder2 after removing e:\folder1
    //but startPath needs to be at least 2 characters long (this is to not touch fullPath when "" or "\") and be smaller than fullPath (this is to avoid an error in substr)
    //yet, we deal with slashes in StartPath, but not in FullPath (we trust FullPath uses only /)
    define('SCROLLGALLERY_SITEBASE_HOMEPATH'  , ABSPATH);
    function nggSGStartPath ($strStartPath = "", $strFullPath = "", $intMinLen = 2){
     		if (strlen($strStartPath)< $intMinLen)              return (string) $strFullPath;          // does nothing
    		if (strlen($strStartPath) >= strlen($strFullPath))  return (string) $strFullPath;          // does nothing
    
    		$strStartPath = str_replace("\\","/", $strStartPath );  // any slash (\) must be translated in (/) to be web friendly as in FullPath
    
    		if (strtolower($strStartPath)==strtolower(substr($strFullPath, 0, strlen($strStartPath)))) {
    				// if we found startPath in the begining of FullPath then we cut it off.
    				$strFullPath = substr($strFullPath,strlen($strStartPath));
    				return (string) $strFullPath;
    		}         
    
    return (string) $strFullPath; // does nothing
    }
    Plugin Author Benedikt Mo

    @bmodesign2

    Hi miguelpinheiro,
    thank you very much for that fix.
    I will check your code and will integrate it in the next version.
    Best regards Benedikt

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Filepath to Images Not Correct’ is closed to new replies.
Skip to toolbar