Voyager: Backslashes in media asset path when saving to db

Created on 16 Mar 2018  路  6Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.6.12
  • Voyager Version: dev-1.x-dev
  • PHP Version: 7.1
  • Database Driver & Version:
    10.1.19 MariaDB

Description:

Encountering an issue where media asset paths being saved to database are using back slashes \ instead of forward slashes /

//view
<div style="background-image:url('{{  Voyager::image($page_data->image); }}');"></div>

//browser output
<div style="background-image:url('http://voyager.lar/storage/pages\March2018\j5hUZQly1g9m7x7YM2uT.jpg'); "></div>

Double checked my storage & file system config & all聽seems to set correctly, as the image paths are being rendered, just with the weird slash issue. I was able to fix the paths using str_replace with my controller, but am trying to understand if this is a voyager error or if there's another underlying issue unique to my environment causing this behavior.

  • When uploading an image via admin, relative path is being saved in the db using forward slashes pages\March2018\L2GNsd5rkrxFMb4G7Rcx.jpg
  • Image media paths renders correctly with forward slashes when image is viewed within voyager media panel.

Environment:
Win7 xampp with vhost aliasing enabled.

Steps To Reproduce:

  • Upload image file to media library
  • Output image within a view using the Voyager::image() helper

Possible Causes

  • Changes made in 1.x-dev branch from slashes to DIRECTORY_SEPARATOR
bug

All 6 comments

Fixed in #2837

I am getting this in v1.1.3 but it was working fine before the update

I'm also still having this issue in the current newest version. Every time I upload an image (creating a new record) I get backslashes. using Windows 10.

Thanks for the tip!

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

craigb88 picture craigb88  路  3Comments

raoasifraza1 picture raoasifraza1  路  3Comments

rayqiri picture rayqiri  路  3Comments

winex01 picture winex01  路  3Comments

TXRRNT picture TXRRNT  路  3Comments