Sphinx link to static file - python-sphinx

I have an RST document like this in source/chapter1/section1/intro.rst:
Test Static Path:
=================
{{ pathto('_static/_resources/intro-01_v3.mp4') }}
What I Need:
============
.. raw:: html
<video width="100%" height="540" controls>
<source src="{{ pathto('_static/_resources/intro-01_v3.mp4') }}" type="video/mp4">
Your browser does not support the video tag.
</video>
But the output of sphinx make html command for this block doesn't run the pathto function and both video source and test section will be {{ pathto('_static/_resources/intro-01_v3.mp4') }} itself.
I want to show the video inside the browser, so I can't use :download: or .. image::.
Is there a way to get a link/path to a file in _static directory?
I need something to GENERATE ../../_static/_resources/intro-01_v3.mp4.

As mentioned by mzjn in comments, by configuring sphinx-jinja and using .. jinja:: directive, it will render pathto.

Related

How to use #nuxt/image with image from assets

I try to use #nuxt/image with image from assets folder; when using image from static folder or external url, the image is optimised as well; but when on using it on image from assets like below:
<nuxt-img
src="~assets/img/Icone-accueil/row_left.svg"
alt=""
class="float-left margin-fleche"
quality="30"
/>
I have this result in my html
<img src="/_ipx/q_30/_nuxt/assets/img/Icone-accueil/row_left.svg" alt="" class="float-left margin-fleche">
but the image doesn't appear
Using #nuxt/image with images from the assets/ folder does not work.
The following is from the #nuxt/image documentation:
Images should be stored in the static/ directory of your project.
For example, when using <nuxt-img src="/nuxt-icon.png" />, it should
be placed in static/ folder under the path static/nuxt-icon.png.
Image stored in the assets/ directory are not proccessed with Nuxt
Image because those images are managed by webpack.
From nuxt documentation:
Inside your ‍‍vue templates, if you need to link to your assets
directory use ~/assets/your_image.png with a slash before assets.
In your case:
<nuxt-img
src="~/assets/img/Icone-accueil/row_left.svg"
alt=""
class="float-left margin-fleche"
quality="30"
/>
Another quote from nuxt:
When working with dynamic images you will need to use require
<img :src="require(`~/assets/img/${image}.jpg`)" />
In your case check this out:
<nuxt-img
:src="require(`~/assets/img/Icone_accueil/row_left.svg`)"
alt=""
class="float-left margin-fleche"
quality="30"
/>
As per Nuxt Image doc, default direcrtory for images is /static, you can change it by update nuxt.config file as below.
e.g,
image: {
dir: 'assets/images',
},
Now you can rewrite as,
<nuxt-img
src="/Icone-accueil/row_left.svg"
alt=""
class="float-left margin-fleche"
quality="30"
/>
This worked for me:
< img :src="require (~/assets/image.jpeg)"
alt=""
/>
For Nuxt3 users whom are using the edge version, which is v1, of nuxt/image,
if you are self-hosting, place images in the 'public' directory as opposed to 'static'.
Quote from v1 docs:
With default provider, you should put /nuxt-icon.png inside public/ directory for >Nuxt 3 make the above example work.
v0 (Nuxt2)
/static/images/myImage.jpg
v1 (Nuxt3)
/public/images/myImage.jpg
Then, access images in the same way others have described. Nuxt/image v1 does not seem able to read a dir named static and of course doesn't read assets as that is used by Webpack.

Not able to display images in blade template

I have Image in public/storage/images directory. I am accessing them with the asset()
<img src="{{ asset('/storage/images/img_1.jpg') }}" alt="Image" class="img-fluid">
But they are not getting displayed.
have you created the symbolic link? If not you can do so by running the command below.
php artisan storage:link
For further information, do refer to the official documentation
Try to use the following, if your image in the asset folder.
<img src="{{ asset('/images/img_1.jpg') }}" alt="Image" class="img-fluid">

Laravel 5.5 image is not showing from storage/app

I am using laravel 5.5. I have a form to upload image. Those images are storing into the storage/app folder. It is working fine. But when I try to show those images. Those are not showing.
I have tried with those ways to print my images.
<img src="{{ asset('storage/1539872957.a-nice-place-to-picnic.jpg')}}" alt="">
<img class="user_avatar" src="{{ url('storage/app/1539872897.IMG_20180804_120323.jpg') }}">
<img class="user_avatar" src="<?php echo asset('storage/1539455504.prakruth-resort.jpg');?>">
Here I am giving image name as static name just for checking.
I have also done php artisan storage:link and a shortcut folder named 'storage' is created in the public folder. But still images are not showing.
i think this Answer would help you.
you will have to create symlink from public/storage to storage/app/public first through this command
`php artisan storage:link`
Now any file in /storage/app/public can be accessed via a link like:
http://somedomain.com/storage/image.jpg
In your Controller use public driver like this:
\Storage::disk('public')->put('file.png',file_get_contents($request->file->getRealPath()));
the above file.png would be stored in 'public/storage'.
now you can access the image file like this:
<img src="{{ asset('storage/file.png'); }}" />

Symfony3 display an image with asset

Symfony gets on my nerves...
I'm desperatly trying to display an image using the following codes and commands :
{% image 'EC/myBundle/Resources/public/images/my-image.jpg' %}
<img src="{{ asset_url }}" alt="Example" />
{% endimage %}
or
<img src="{{ asset( 'images/my-image.jpg' ) }}" />
with
php bin/console assets:install
or with
php bin/console assetic:watch
or with
php bin/console assetic:dump --env=dev
I've been trying everything but it doesn't work at all.
(However, CSS and JavaScript do work (using the proper tag).)
I don't understand where the problem comes from.
Thank you for your help.
Try something like this :
img src="/bundles/app/images/logo.png"
and make sure the file exists in the web folder

Why images folder is not copied when generating an Octopress with jekyll-assets blog?

I am building an Octopress blog and I am implementing an alternative search implementation, lunr-search.
This requires an asset pipeline implementation for Jekyll.
My assets, javascripts and CSSs are compiled and combined correctly, but my images folder is not copied to the public folder.
EDIT with further info:
I have my assets under /source/_assets/javascripts, /source/_assets/stylesheets and /source/_assets/images.
The relevant part in _config.yml:
assets:
dirname: assets
baseurl: /assets/
sources:
- _assets/javascripts
- _assets/jwplayer
- _assets/stylesheets
- _assets/images
compress:
js:
css:
cachebust: hard
gzip: [ text/css, application/javascript ]
My compiled and combined assets are generated as expected under /public/assets, under which I can find the app.js and screen.css, however there is no images folder.
Thanks!!
Have you rewritten your source to use Jekyll-Assets to render image paths? In my experience, Jekyll-Assets needs to know you'll be using an asset before it will copy it to the output directory. It will know when you use a corresponding Liquid tag or filter.
According to the Jekyll-Assets readme, URLs for assets that are neither scripts nor stylesheets may be included with the following Liquid tag:
{% asset_path logo.png %}
Additionally, the following Liquid filter is available:
{{ 'logo.png' | asset_path }}: Returns resulting URL for logo.png
Both examples come from the URL above. So in this case the following two lines would be equivalent:
<img src="{% asset_path logo.png %}" alt="Logo">
<img src="{{ 'logo.png' | asset_path }}" alt="Logo">
If you are indeed already doing this, relevant HTML/Liquid source code may prove helpful.
This did the trick for me
{% img /images/logo.png %}

Resources