images from static folder in nuxt 3 doesn't show - vue.js

I'm using Nuxt 3
and this is directories structure
images are loaded like this
<img src="/images/index/pic-left.svg" />
I've also tried (start without / )
<img src="images/index/pic-left.svg" />
and it didn't worked again
What's the problem ?

In Nuxt3, the directory is now public and not static.
So it should be /images/index/pic-left.svg.

Related

Nuxt js static pages relative URL change my link button

I am working on some static pages using Nuxt.js (MPA). Whenever I run the generate command, all URLs start from page, i.e /customer/. For example, my structure is:
pages
|customer
|new
- index.vue
- index.vue
And in index.vue I have linked to customer/new page as:
<nuxt-link to="customer/new"> <b-button class="btn-sm btn-success" >nuevo</b-button></nuxt-link>
all works fine if I use:
npm run dev
But if I use:
npm run generate
the link in the button link change to /customer/customer/new instead of /customer/new.
Thank you.
Your link have to be relative to the base URL of your app, see https://nuxtjs.org/api/configuration-router#base
So to fix your issue, declare your link with a starting slash as follows:
<nuxt-link to="/customer/new"> <b-button class="btn-sm btn-success" >nuevo</b-button></nuxt-link>

React-Native-Pdf can't set the source from the app iteself

In my RN application, I use react-native-pdf. I want to show a file which is in the file system of the app. But when I set the source it doesn't work and the app can't identify the path. How can I set the path properly?
<Pdf
source={{ uri:'file:///terms.pdf'
/>
It should be below. when I tried that, it worked. And there is no bug about that on the repository of react-native-pdf. Maybe your version of react-native-pdf has bug. You should get this version => 5.1.6.
<Pdf
source={uri:"file:///absolute/path/to/terms.pdf"}
/>

importing images in Vue component template

i created a vue project using vue-cli 3 and while working in my local env i managed to present all images in components html part the following way:
<template>
<img class="logo" src="#/assets/images/logo.svg" alt="logo">
</template>
in my machine the full path to the image (starting from the src folder as root) is src/assests/images/logo.svg
when running the project on the local env the image loads and it's source is
/assets/images/logo.svg which redirects to http://localhost:8080//assets/images/logo.svg.
now when i upload the project to my staging env the source changes (and i cant figure out why) to src="/img/logo.230e726c.svg" and the image is missing.
following info i found online i also tried:
src="~#/assets/images/logo.svg" which didn't work as well .
any idea what am i missing here and how should i import images in my template? or how did the source url turn to this (what seems to be quite random) path?
UPDATE
i noticed that on my local machine , when inspecting the result in the dev tools, the content type is Content-Type: image/svg+xml; charset=UTF-8 and when inspecting on staging the content type is content-type: text/html
plus there also another header which only appears in staging and its content-encoding: gzip
, i'm not sure but does this should serve as some clue??
another thing worth mentioning, when trying to upload png every thing works fine and the image elemnt looks like this:
<img data-v-7d622f5c="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAwCAYAAADn/d+1AAAMwklEQVR42u2bC5SVVRXHmZk7w4ADgzM8RoZHQLzk/Q4UQVAhYEAEBEUQ8UGsABNUCoiHBCZQFIRKalEUgkX2QHvgo2gVRhCFoSAPMWKJiWGFDDDMve2Nv5Pb0/fdxyAyLOastde99/u+fc759t5n7//e59xKlSpaRatoFa2ihbVYLHaZUA+hfkLDhMYI3SF0m1CRUFuh6gF8nxLqA28k4H6W0NU8U1CGeTUWKkyRR8esJpSeAk9dodZC2eVFIV+KRqNvCx2T76eEorH3W6lQsdABoe+rYjy+7wi9K/R3oUsD+m0gdJRnhqQ4pzEynx1Cvw0yhhCemvouQmuFBiWjFHkmT8b4ldDr8n1yeVHIMqGTKCCKAPfIJA/K53tcL5XfP7aCl+/dUdxpoaYB/balP73fP4X5XCq0H16lxkny3SJz/DfzfUGoRiIeef4rPK/tZ+VFIY3UVWElKoCFXE8TainXn2TCJ4TaGb7qKEx5Hg7odxB8quxrvHvZKkChiUJtnLtQqxaaCo+2bdaV4F4vD3Gh/TCiEqHVQjlCmWoMQg8IDRWqY55vxwrWdlzouvIUR9rKy+y2CjH3GjJpvXeLd+85rr8R0Odk+FRpvb17rbiuLvI1oaUoprnQFvpUIU20K0fm+KLQq/J9vbpBFbinZI2D44WaYVCfENpKf/8U3l/K5ziU+oRxzz8KioPlVSFVYx+0md69u41baubdW3pGi9Hov+TjSu9efWJWNBbetqsxeBZdamOc+n8/tnnj5MszP/X4/KYu+tPlDWmVVSFXYMnKN8W7twae/QGAIAKCe1rGPRIirN8I1fL4Fmp8wwBiRuGrcE05IS55vtBfjCuMGf43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wHaWcDMlK0s0tIngrTU+S53pz5nhRmc6QAWEHAl+vB1fncQC5OdbfDWusgWJ64N7SKUOMwGKGYf3DuJ9DvzeyyjqyKgaxv9AOyG3LEHfxeS0urQVKdgoZSjLZHt405hlvhYwikHZOQS45wPppYadqQox7Li4872yCXiYrJNOgkiw+M6A0k7dken+GjLh7pr9083yWcQ8Rd9yS32leMhgxfGmWvDE+tKOZBMrK/JgARCSlAmJFq2gVraJdWO2/87NTjPDRSvwAAAAASUVORK5CYII=" alt="logo" class="logo">

VueJS Image Tag Source is not working, how can i fix it?

I have the following img tag :
<img class="logo" src="../../assets/logo/logo_blue.png">
project structure
I don't know why but I only get the following error message:
GET http://localhost:8080/assets/logo/logo_blue.png 404 (Not Found)
try <img class="logo" src="#/assets/logo/logo_blue.png">
here '#' refers to root directory
will this work?
<img class="logo" src="./assets/logo/logo_blue.png">
I believe the path to that image entirely depends on the relative path between the page and image at deployment time. If you're not using HTML5 history mode, this ./assets/ prefix should always work.

Specifying static images directory path in Django

I tried to use an image file in my HTML template. But when I run the server and open it in the browser the image is not getting loaded. But if I run the HTML file individually it's working fine. I mentioned the path of images folder in file settings.py, MEDIA_ROOT, also. Still it is not working.
settings.py:
MEDIA_ROOT = 'C:/Users/Vicky/Documents/Django/krish/media/images/'
HTML:
<img src="../media/images/Untitled.jpg" width ="267" height="122">
I also tried giving:
<img src="Untitled.jpg" width ="267" height="122">
How can it be made to work?
I had this problem when I started Django too :)
The Django server does not serve static files by default. Usually you need to use a separate server for this, but in a development environment you can use a shortcut.
Add this to your urls.py:
if settings.DEBUG:
urlpatterns += patterns('',
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}),
)
Don't use this in production. It is slow, unstable and insecure.