havana97 Posted April 28, 2018 Share Posted April 28, 2018 Hi, Am I right is assuming that an uploaded image is only available to that specific page and not any other pages via the admin? Regards Link to comment Share on other sites More sharing options...
teppo Posted April 28, 2018 Share Posted April 28, 2018 Depends on your use case, but.. that's not entirely true. When you embed an image into a CKEditor field, for an example, you get to choose from which page you want to pick the image from. Similarly you can request an image from any given page via the API in your template files. So no, an image is not strictly tied to one page: you can embed images anywhere, and you can indeed use them in multiple places on your site. There are also some modules that make reusing media easier, such as MediaLibrary (free) and Media Manager (commercial). It is true, though, that behind the scenes an image is always connected to a single page, and because of that ... A) you can't have a single image showing up in image fields of multiple pages, B) only one copy of each image file is stored in a page-specific directory under /site/assets/files/, and C) if you have restricted access to a given page and enabled $config->pagefileSecure, access to files (including images) on that page will also be restricted. 3 Link to comment Share on other sites More sharing options...
pwired Posted April 28, 2018 Share Posted April 28, 2018 Hi, and welcome, You can get any image from any page with the $pages variable. Basic use is like this: $image = $pages->get('/path/to/page/')->imagefield-> Examples: $mypage = $pages->get('/path/to/mypage/'); $myimage = $mypage->images->get("name=myimage.jpg"); You can also use shorthand rules or hanna code to write more compact code More here:https://processwire.com/api/variables/pages/ 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now