Typo3 - Images aren't found on "sub paths" (no absolute path) - typo3

I wrote a Typo-3 template which is working fine the problem is that when I call a "sub path" the image links aren't found anymore.
/index.php: every thing works fine
/test/index.php: images aren't found anymore
The problem is that no image url is an absolute path whether from TypoScript or from fileadmin via component.
Is there a way to force absolute path use everywhere?

I assume you use an extension to get nice URLs (coolUri or realUrl) so you get path segments for each page other than the root page.
So you have subfolders in your URL but always the index.php from your webroot is called.
Now you have images which by default are referenced relative to the working php script. As the working php script is /index.php a path to fileadmin/img/image1.jpg is correct.
But your browser thinks you are in path /test and requests an image <domain>/test/fileadmin/img/image1.jpg, which does not exist.
Either your browser needs to know which base to use for server pathes (setting base Url),
or (better) you provide absolute URLs for any resources. This can be done with a little typoscript configuration:
config.absRefPrefix = /

Related

direct routing to TYPO3 extension files

I am a maintainer of the TYPO3 extension QFQ.
Our extension accesses many of its files directly by links relative to index.php of TYPO3. For example it requests the following API file via JavaScript in the frontend:
/typo3conf/ext/qfq/Classes/Api/file.php
Since the upgrade to spoken URLs with TYPO3 v9 these relative paths stopped working. For example the above relative path would result in the following url when clicked on in the browser:
example.com/en/.../typo3conf/ext/qfq/Classes/Api/file.php
instead of:
example.com/typo3conf/ext/qfq/Classes/Api/file.php
We have seen that one can add static routes to single files in the TYPO3 backend (Sites > Edit > Static Routes > Create new) but this does not seem to allow us to set the whole extension directory /typo3conf/ext/qfq as a static route. Since many files are accessed this way, it is way too tedious to set a static route for every single fie on every installation of TYPO3 which uses our extension.
Our own "dirty" solution to this problem would be to add a new rewrite rule to the .htaccess which rewrites any url containing typo3conf/ext/qfq. It would remove any path before typo3conf.
My question is: Is there a better way to solve this problem? How do other extensions create links directly pointing to the files inside the extension directory? Are we missing something obvious?

ModX Evo places page name in image path URL. How to disable this?

I just upgraded a site from 1.0.5 to 1.0.12 and am having troubles with images. It seems that now when I save a resource, ModX or TinyMCE places the name of the resource in the path for whatever images I have in that resource.
So, formally, my image paths looked like:
www.mysite.com/assets/images/photo.jpg
but now they look like:
www.mysite.com/page-name/assets/images/photo.jpg
This has broken all the images on my site. Further more, adding a new image or finding the old ones via the file browser doesnt work either. It just inserts them with the proper path, but updates them with the new path upon save, having the same effect.
Does anyone know what I can do to solve this?
Just specify "base url" in "head" tag - <base href="http://your_site.com/" >

Debugging Responsive File Manager Plugin (TinyMCE)

Yesterday I found this great looking plugin for file and image management for tinymce however I cannot get the files to actually save to the drive. I have tried every commbination I can think of.
responsivefilemanager.com - This plugin.
Anyone used it before and know of the settings I might need?
The plugin sits here: /public_html/cms/app/webroot/js/tinymce/plugins/filemanager
I'm trying to set it up so the uploads go here: /public_html/cms/app/webroot/files/cms
The config file for the plugin has 3 lines to configure for this, these are as follows and as I have set them up:
$base_url="http://domain.com/cms/"; // base url of site. If you prefer relative urls leave empty
$upload_dir = 'app/webroot/files/cms/'; // path from base_url to base of upload folder
$current_path = '../../../files/cms/'; // relative path from filemanager folder to upload folder
Now when I started working this out I would get an error for the plugin saying the root folder doesn't exist so I keep playing with the paths and now I don't get this error but I still cannnot get it to upload the images, everything looks like it works, I get the preview as the image is uploading and a green tick once it's complete then I go back to the files list and the image isn't there. It's not on the server either. I'm wondering if there is a way to debug this and work out what's happening?
Thanks
I ended up getting this to work with the following settings:
$base_url="http://domain.com"; // base url of site.
$upload_dir = '/cms/app/webroot/files/cms/'; // path from base_url to base of upload folder
$current_path = '../../../../files/cms/'; // relative path from filemanager folder to upload folder
Thanks
Try the following settings if you still have not got this sorted out yet:
$base_url="http://www.domain.com/cms"; // base url of site. If you prefer relative urls leave empty --> No trailing slash
// The upload directory will be a dir you have created for the files to be uploaded to, ie: localhost/cms/app/webroot/files/cms --> this file must have write permission.
$upload_dir = '/app/webroot/files/cms/'; // path from base_url to base of upload folder --> write permission (chmod = 755)
$current_path = '../../../../files/cms/'; // relative path from filemanager folder to upload folder (you are missing one "../")
// The thumbs folder located in tinymce/plugins/filemanager/thumbs must also have write permission (chmod = 755)
That should do it
use gsynuhimgupload plugin TinyMCE
http://gsynuh.com/tinymce-simple-image-uploader/136
TinyMCE simple image uploader
Here’s a repost of my TinyMCE image uploader plugin. It used to be on gsynuh-labs.com (but I let this domain go).
please note that this plugin is no longer supported by me – and I’m not responsible for any inconvenience caused by it, it is shared “as-is” and you have to be responsible when using it ie: take care of any possible injection problems/security problems in your own site’s context.
I’m not interested in expanding it myself as I was only looking for a very minimal image uploading plugin for myself but If you are going to expand on it, I can list your version on this page if you want, just contact me.
—

Using local resources in an iPhone webview

Suppose an app has a webview that uses JQuery for example.
The server delivers the page with appropriate links to load JQuery, and the view works fine, but I would like it to not need to download JQuery (yes it may be cached, but it won't be the first time the app runs and I would rather not count on it)
So I can include the JQuery files with the app, but then how should I embed the links?
The server certainly doesn't know the bundle path.
I thought I could load the url into a string and then replace the JQuery paths with the local paths before displaying in the webview.
Is there an easier way?
You can use relative paths for jQuery and set the baseURL to the bundle path. However that requires that all resources are in the bundle directory (except those which are referenced by an absolute path).

PhoneGap Relative URL

I've build a mobile site using jQTouch, and now I've been working to get that same site working with PhoneGap. For PhoneGap, I've moved most all of the assets (pages, images, JS, CSS, etc.) into the www directory, but I still need to load some dynamic content via Ajax. From the mobile site, I'm using relative URLs to load additional content. However, with PhoneGap, I haven't found a way to use relative URLs to access my mobile site and have been forced to use absolute URLs. My question is this: Is there a way to use relative URLs with PhoneGap? Maybe something like setting a base URL during the PhoneGap initialization?
When using PhoneGap the main files will be on the phone so relative files will be relative to the location on the phone.
If you need to access a file on a remote server (your mobile site) then it must be specified absolutely.
If your main HTML page within your PhoneGap app is at file://www/index.html and you try and access a relative file (say "logo.png") and so specify <img src="logo.png" /> you're really getting it from file://www/logo.png.
If you actually wanted the version of logo.png which is actually on your remote website, you have to provide the full (absolute) path or there's no way for the browser to know that when you specify "logo.png" you mean the one at "http://www.your-site.com/logo.png".
You can try using the <base> tag. This will set your Base URL to whatever you need:
<base href="http://yourdomain.com/">
<script src="js/remotescript.js"></script>
Note this means now your local scripts need to be in absolute form:
<script src="http://localhost/js/phonegap.js"></script>
See this other question for more info regarding this note. The guy there suggests to prepend a dot (.) before the local relative URL, though I didn't test this:
<script src="./js/phonegap.js"></script>
I know this is 6/7 years old, but for any others arriving here for the same question...
Here's a solution, since there isn't a more "packaged" one:
3 quick steps:
1) Store your site domain in a global javascript variable
var currentloc = 'https://example.com'
2) Use temporary variable to add your relative path to currentloc
var relpath = '/need/jsonex'
var ajaxcall = currentloc + relpath
$.ajax({...
3) Adjust currentloc if you do change the supposed "location" that you're calling relative path from on site
currentloc = currentloc + '/new/path'
** just remember if you make currentloc a global variable you need to keep track of these changes.
Hope this helps.