Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media Routing problem using PHP Built-in Web Server #1119

Closed
ricardo118 opened this issue May 25, 2017 · 5 comments
Closed

Media Routing problem using PHP Built-in Web Server #1119

ricardo118 opened this issue May 25, 2017 · 5 comments
Labels

Comments

@ricardo118
Copy link
Contributor

I've tested this issue across 3 different windows machines, using the latest php 7.

When launching a localhost via this command:
C:\php\php.exe -S localhost:80 -t C:\projects\core C:\projects\core\system\router.php

Everything works as expected, except when viewing media already uploaded in Admin.js. See picture below:

With the console showing the following error:
Failed to load resource: net::ERR_NAME_NOT_RESOLVED

This is due to the path of the image having an extra slash. By manually removing it, the issue is solved
<img data-dz-thumbnail="" alt="263.jpg" src="\/images/a/4/7/b/3/a47b3570310dd103daf2e3682493d5d389fd289d-263.jpeg">

@rhukster
Copy link
Member

I shall take a look as i've been working on media thumbnails and stuff this week.

@rhukster rhukster added the bug label May 26, 2017
@OleVik
Copy link
Contributor

OleVik commented May 30, 2017

I can replicate this with PHP 7.0.7 on a fresh Grav v1.2.3 + Admin v1.4.1. As Ricardo pointed out, the problem is the backwards-slash at the beginning of the src-attribute, seemingly escaping the following forward-slash. To quote myself from Slack:

Regardless of whether CropZoom is used (line 1524), it returns as src="\/images/....". Its easy to trim, of course, but I expect it deeper down has to do with Windows-paths, which of course by default use backwards-slashes. So it could easily have to do with using DIRECTORY_SEPARATOR unnecessarily, as PHP for at least a few major versions have supported forwards-slashes.

Thus, I suspect it is a remainder from path-interpretation of the system as a whole, which somewhere has not trimmed the final slash of the installation-path, or concatenates a DIRECTORY_SEPARATOR unnecessarily.

@rhukster
Copy link
Member

Can you test if your XHR request for listMedia call has the extra slash?

@OleVik
Copy link
Contributor

OleVik commented May 30, 2017

It is emanating from the Media-iteration, within the method rather than any encoding happening later. As a quick and dirty test, doing this:

$url = $medium->cropZoom(200, 150)->url();
$url = ltrim($url, '\\');
$media_list[$name] = ['url' => $url, 'size' => $medium->get('size')];

resolves it from within the loop.

@rhukster
Copy link
Member

rhukster commented Jun 4, 2017

This should be solved via Ole's PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants