图像资源与Phalcon [英] Image resources with Phalcon

查看:98
本文介绍了图像资源与Phalcon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的样式表中有以下代码:

I have the following code in my stylesheet:

body
{
    margin: 1cm 3cm 1cm;
    background-image:url("bg.png");
    background-position:center top;
    background-repeat:no-repeat;
}

但在服务器上找不到背景。我已经测试了这个代码只有一个基本的html页面,它的工作,必须有一些东西,不允许它在Phalcon框架。

But the background isn't found on the server. I have tested this code with just a basic html page and it does work, there must be something that isn't allowing it within the Phalcon framework.

可能的文件位置的图像?

Possibly the file location of the image? I have it in the same folder as the html file.

推荐答案

是的,我相信您的文件的位置是更改,我的意思是,当你访问一个页面的Phalcon应用程序,所有的服务器端包括将作为当前目录的主要引导文件的路径(主要 index.php 文件路径),对于客户端,浏览器总是认为执行的操作(如 www.myapp.com/users/login-form / )实际上是一个您的服务器上存在目录结构(因此浏览器将尝试在 www.myapp.com/users/login-form/bg.png 中加载您的背景)。

Yes, I believe that the location of your file is "changing", I mean, when you access a page in your Phalcon application, all your server side includes will take as the current directory the path of your main bootstrap file (the main index.php file path), and for client side the browser will always think that the action executed (like www.myapp.com/users/login-form/) is actually a existent directory structure on your server (so the browser will try the load your background in www.myapp.com/users/login-form/bg.png).

这就是为什么Phalcon提供许多方法来提供html资源,不仅解决这个问题,而且使你的应用程序未来的证明(如果你需要移动所有的图像,CSS和JS CDN服务器?),这里是:

That's why Phalcon offers many ways to deliver html assets to solve not only this problem but also make your application future proof (what if you need to move all your images, CSS and JS to a CDN server?), and here it is:

您可以使用 资产管理器 (更高级)或简单的 查看助手 ,它可以根据您的 网址服务 配置。您的应用程序应该有一个有效的URL配置,通过设置所需的基本URI(导致Phalcon控制器的URL)和所需的静态URI(导致CSS文件,图像等的URL),可以找到更多的信息< a href =http://docs.phalconphp.com/en/latest/reference/url.html#static-vs-dynamic-uris =nofollow> 此处

You could either use an assets manager(more advanced) or simply a view helper which can produce all assets URLs needed based on your url service configurations. Your application should have a valid URLs configuration by setting the desired base URI (for URLs that leads to Phalcon controllers) and your desired static URI (for URLs that leads to CSS files, images, etc), more info about this can be found here.

这篇关于图像资源与Phalcon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆