При загрузке изображения произошла ошибка vs code

@doublelam

Issue Type: Bug

when clicking an image from left panel, there’s a great probability encounter this issue, sometimes when you click another image and then re-click the previous image, you won’t encounter this issue, but, mostly, you still get this issue

and when I click the ‘Open file using VS Code’s standard text/binary editor?’ is useless, nothing happened
image

VS Code version: Code 1.44.0 (2aae1f2, 2020-04-08T08:23:56.137Z)
OS version: Darwin x64 19.0.0

System Info

Item Value
CPUs Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz (4 x 3100)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) 6, 6, 6
Memory (System) 16.00GB (0.05GB free)
Process Argv -psn_0_2298417
Screen Reader no
VM 0%

Extensions (6)

Extension Author (truncated) Version
gitlens eam 10.2.1
vscode-gutter-preview kis 0.26.1
vscode-typescript-tslint-plugin ms- 1.2.3
color-highlight nau 2.3.0
vscode-xml red 0.11.0
code-spell-checker str 1.8.0

@gjsjohnmurray

Does the problem also happen if you reload with all extensions disabled?

@doublelam

Does the problem also happen if you reload with all extensions disabled?

was trying to disable all extensions, this issue still exists, I guess it’s related to memory. when my mac has lower memory, I meet this issue more often. anyway, I still meet this issue though it has enough memory, especially when clicking images one by one and preview an image which hasn’t been opened before

@mjbvz

@thunfischtoast

I encounter this issue sometimes when working on a SSH-Remote.
I can reproduce it in the following version with just Remote — SSH extension enabled and nothing else.
Free memory is no issue here.

Version: 1.45.0-insider
Commit: abb4a35
Date: 2020-04-28T05:38:07.215Z
Electron: 7.2.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 4.15.0-96-generic

@tillig

I noticed an earlier ticket with a similar issue where the problem had something to do with a % being in the name of the file or somewhere in the path. I’m seeing this while working on an Azure DevOps wiki where there’s URL encoding in the path.

The image is at /Stand%2DIn-Data/Data-Model-ERD.png in the repo. (This way, in Azure DevOps wiki, it renders as Stand-In Data.) If I move this same image out of that folder to some other location, like /Test/Data-Model-ERD.png it renders just fine. This leads me to believe the % is absolutely the culprit, at least in my case.

I notice that this log message shows up in the Log (Window) output pane when the image fails to render the first time. It only shows up once, regardless of whether I close and reopen the image.

[2020-05-12 07:34:19.980] [renderer1] [error] Cannot read property 'important' of undefined: TypeError: Cannot read property 'important' of undefined
    at e.fetch (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6606:708)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async e.doActivate (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6606:343)
    at async Promise.all (index 2)
    at async e.activateProactiveRecommendations (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6724:681)

Version: 1.45.0
Commit: d69a79b
Date: 2020-05-07T15:57:33.467Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.4.0

@chrisdias

@mjbvz this happens for me 100% of the time when using Remote — WSL. If I open a folder locally I can view the images. Trying to open any images when remote give this error.

There are no errors in the console.

Using latest Insiders

Version: 1.46.0-insider (user setup)
Commit: 9e439b13d5784538333bee044ca1d1a992bc1c90
Date: 2020-05-28T18:44:47.151Z
Electron: 7.3.0
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19041

@github-actions

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

many people find difficulties in displaying image in html document.This is due to incorrect source file (src) path. One of the below method may fix the problem.

UPDATE VISUALSTUDIOCODE TO THE LATEST VERSION:

Updating visual studio code to the latest version might fix the issue. Or else try the other alternative solutions listed below.

IF YOU HAVE THE IMAGE IN THE SAME HTML FOLDER YOU ARE USING:

Then you can add only the image file name like this.

IF YOU HAVE THE IMAGE FILE OUTSIDE THE HTML FOLDER IN THE WORKSPACE:

Then copy the relative path and add a slash to it.

IF YOU HAVE THE IMAGE IN A FOLDER WITHIN THE HTML FOLDER:

Then add the folder name followed by the slash and the image file as shown below.

IF YOU HAVE THE IMAGE AS A LINK:

Search the image name in the source code of the website and copy the src and paste it in your code.

TRY CHANGING THE WORKSPACE FOLDER:

You have been specified the path in outside the work space you are using. Try to change this by clicking FILE->OPEN WORKSPACE.

I HOPE IT HELPS 😇

IF YOU HAVE ANY OTHER RELATED QUESTIONS COMMENT BELOW.

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Assignees

@mjbvz

Labels

bug

Issue identified by VS Code Team member as probable bug

help wanted

Issues identified as good community contribution opportunities

markdown

Markdown support issues

verified

Verification succeeded

Any time I try to use an image from my local machine, I get an error from VS Code saying «An error occurred while loading the image. Open file using vs code’s standard text/binary editor.»
The original drag and drop of the image into the file functions as in I can see the image in the text editor but if I click onto another file/folder and back onto the image file, I get this error. This is happening in this instance while trying to use a .ico file but it has been happening for about a week now with any image I try to use (.png, .ico, .jpg, etc…). I am on a Windows 10 machine and memory is not an issue.

I have tried disabling all extensions, replacing the file with another, making sure VS Code is up to date and completely closing VS Code and re-opening it.

asked Nov 1, 2022 at 18:35

Antonio DiCerbo's user avatar

Alright, I got the same issue last week, and this was how I fixed it:

Go to where you saved the project on your laptop, then drag and drop the images there. This should reflect in your VS Code.

Once the images were added through this route, they would not bring the initial error.

Let me know if you got what I said or if a short video will help!

answered Feb 6 at 9:31

John Fáwọlé's user avatar

@doublelam

Issue Type: Bug

when clicking an image from left panel, there’s a great probability encounter this issue, sometimes when you click another image and then re-click the previous image, you won’t encounter this issue, but, mostly, you still get this issue

and when I click the ‘Open file using VS Code’s standard text/binary editor?’ is useless, nothing happened
image

VS Code version: Code 1.44.0 (2aae1f2, 2020-04-08T08:23:56.137Z)
OS version: Darwin x64 19.0.0

System Info

Item Value
CPUs Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz (4 x 3100)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) 6, 6, 6
Memory (System) 16.00GB (0.05GB free)
Process Argv -psn_0_2298417
Screen Reader no
VM 0%

Extensions (6)

Extension Author (truncated) Version
gitlens eam 10.2.1
vscode-gutter-preview kis 0.26.1
vscode-typescript-tslint-plugin ms- 1.2.3
color-highlight nau 2.3.0
vscode-xml red 0.11.0
code-spell-checker str 1.8.0

@gjsjohnmurray

Does the problem also happen if you reload with all extensions disabled?

@doublelam

Does the problem also happen if you reload with all extensions disabled?

was trying to disable all extensions, this issue still exists, I guess it’s related to memory. when my mac has lower memory, I meet this issue more often. anyway, I still meet this issue though it has enough memory, especially when clicking images one by one and preview an image which hasn’t been opened before

@mjbvz

@thunfischtoast

I encounter this issue sometimes when working on a SSH-Remote.
I can reproduce it in the following version with just Remote — SSH extension enabled and nothing else.
Free memory is no issue here.

Version: 1.45.0-insider
Commit: abb4a35
Date: 2020-04-28T05:38:07.215Z
Electron: 7.2.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 4.15.0-96-generic

@tillig

I noticed an earlier ticket with a similar issue where the problem had something to do with a % being in the name of the file or somewhere in the path. I’m seeing this while working on an Azure DevOps wiki where there’s URL encoding in the path.

The image is at /Stand%2DIn-Data/Data-Model-ERD.png in the repo. (This way, in Azure DevOps wiki, it renders as Stand-In Data.) If I move this same image out of that folder to some other location, like /Test/Data-Model-ERD.png it renders just fine. This leads me to believe the % is absolutely the culprit, at least in my case.

I notice that this log message shows up in the Log (Window) output pane when the image fails to render the first time. It only shows up once, regardless of whether I close and reopen the image.

[2020-05-12 07:34:19.980] [renderer1] [error] Cannot read property 'important' of undefined: TypeError: Cannot read property 'important' of undefined
    at e.fetch (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6606:708)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async e.doActivate (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6606:343)
    at async Promise.all (index 2)
    at async e.activateProactiveRecommendations (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6724:681)

Version: 1.45.0
Commit: d69a79b
Date: 2020-05-07T15:57:33.467Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.4.0

@chrisdias

@mjbvz this happens for me 100% of the time when using Remote — WSL. If I open a folder locally I can view the images. Trying to open any images when remote give this error.

There are no errors in the console.

Using latest Insiders

Version: 1.46.0-insider (user setup)
Commit: 9e439b13d5784538333bee044ca1d1a992bc1c90
Date: 2020-05-28T18:44:47.151Z
Electron: 7.3.0
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19041

@github-actions

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

В vscode с помощью плагина live server работаю с png. Во вкладке открытой с помощью плагина png отображается как надо, а если просто открыть html файл, то просто alt, на хостинге тоже ничего не отображается. Остальные форматы отображаются без проблем.

<img class="light" src="/img/lighwerwerwerwert.png" alt="Светильники">

Пример img

Некоторые изображения накладываются друг на друга слоями с помощью: z-index: х; position: absolute; в частности 2 png + 2 svg. Работает только 1 png + 2 svg вторая png не хочет.
Что делать, как решить?


  • Вопрос задан

    более двух лет назад

  • 2926 просмотров

<img class="light" src="./img/lighwerwerwerwert.png" alt="Светильники">

Пригласить эксперта

Немного дополню предыдущего комментатора:
1. если ссылка начинается с «/» — это значит «начать с корня сайта (или диска). например ссылка вида /images/image.png будет искаться либо по адресу site.ru/images/image.png, а локально — относительно того раздела на винте (c:/images/image.png), где находится файл html. При этом не будет браться в расчет путь к каталогу, где находится html. Ссылка получится «абсолютной».
2. если ссылка будет без дроби вначале вида «images/image.png» — путь к изображению будет строиться от места нахождения файла html. Например: файл лежит в каталоге «c:/work/site/index.html», тогда рядом с ним должен находиться каталог images с картинкой, и браузер будет открывать картинку по следующему пути: «c:/work/site/images/image.png».
Ссылка без дроби вначале сработает аналогично «./images…»
точка с дробью принудительно указывает на текущий каталог, в котором лежит файл html. Ссылка получится «относительной» (т.е. будет строиться относительно местонахождения html файла)

live в редакторе позволяет имитировать работу на сайте и подставляет корневой каталог от местонахождения файла html. Если будет более сложная структура — и live может не помочь, если будете так ссылки выстраивать. Для локальной верстки используйте только относительные ссылки. При необходимости обратиться в соседний по уровню вложенности каталог ссылка может начинаться с «../», что укажет браузеру необходимость подняться на один уровень вложенности выше.


  • Показать ещё
    Загружается…

30 янв. 2023, в 23:32

5000 руб./за проект

30 янв. 2023, в 23:11

500 руб./за проект

30 янв. 2023, в 22:43

1500 руб./в час

Минуточку внимания

Тип проблемы :

Я заметил, что каждый раз, когда я пытаюсь открыть изображение в коде vs, я получаю сообщение об ошибке, указанное в заголовке, независимо от типа файла изображения.

Версия кода VS: Код 1.39.2 (6ab598523be7a800d7f3eb4d92d7ab9a66069390, 2019-10-15T15: 33: 00.827Z)
Версия ОС: Darwin x64 18.7.0

Системная информация

| Товар | Значение |
| — | — |
| Процессоры | Intel (R) Core (TM) i7-6820HQ CPU @ 2,70 ГГц (8 x 2700) |
| Состояние графического процессора | 2d_canvas: включен
flash_3d: включен
flash_stage3d: включен
flash_stage3d_baseline: включен
gpu_compositing: включен
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: включен
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
растеризация: включена
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: включен
viz_display_compositor: disabled_off
webgl: включен
webgl2: включен |
| Нагрузка (средн.) | 2, 2, 2 |
| Память (системная) | 16,00 ГБ (6,19 ГБ свободно) |
| Обработка Аргв ||
| Программа для чтения с экрана | нет |
| ВМ | 0% |

Расширения (21)

Расширение | Автор (усечено) | Версия
— | — | —
html-фрагменты | abu | 0.2.1
vscode-browser-preview | auc | 0.5.9
рельсы | булочка | 0.13.1
vscode-gemfile | булочка | 0.0.2
солнечограф | cas ​​| 0.21.1
vscode-eslint | dba | 1.9.1
code-runner | для | 0.9.14
vscode-rufo | jnb | 0.0.1
vscode-gutter-preview | кис | 0.23.0
привязки клавиш атома | ms- | 3.0.6
vsliveshare | ms- | 1.0.1056
отладчик для хрома | msj | 4.12.0
erb | Rie | 0.1.1
LiveServer | rit | 5.6.1
ActiveFileInStatusBar | Ros | 1.0.3
тонкий | sia | 0.1.2
html-превью-vscode | tht | 0.2.5
выделение-сопоставление-тег | vin | 0.9.5
простой-рубин-эрб | вор | 0.2.1
quokka-vscode | Wal | 1.0.257
erb-vscode-snippets | Zne | 0.0.4

bug
help wanted
markdown
verified

У меня такая же проблема с установленной копией.

@mjbvz Обнаружил, что проблема
Если в имени файла есть символ%, vscode не отображает изображение.
Screen Shot 2019-10-30 at 12 17 40 PM

Если я удалю символ% в имени файла, vscode отобразит изображение правильно.

Проверено как в текущей стабильной версии Mac, так и в сборке для инсайдеров.
@aparcanapavel Сообщите нам, если вы наблюдаете ту же закономерность.

Даже если я столкнулся с той же проблемой, и мое имя файла изображения не содержит символа%, решите мою проблему.

В моем файле тоже нет символа%, и он не работает.

не отображается картинка

  • Главная
  • Вопросы

в редакторе vs code не отображается картинка 

не пойму как правильно указать путь

при переносе файлов в редактор,они одновременно попадают и в папку img и в css 

и после на сайте не картинка а зеленый квадратик

пробовал добавлять и css при указании пути,результат тот же

 <div class="content">
                <h1>Новые фильмы</h1>

                <div class="films_block">
                    <a href="#"><img src="assets/img/matrix.png"></a>
                    
                </div>

Максим Потапов

1 year ago


  • Активные
  • Старые
  • Голоса

зайдите на диск в свою рабочую папку — через Проводник или менеджер файлов и там порядок наведите — создайте нужную структуру папок и поместите файлы картинок в нужную папку.

а дальше откройте вашу рабочую папку в VSCode и используйте созданные папки и файлы

и учитывайте что путь к файлу картинки указывается относительно папки где ваш html-файл лежит


михаил спасибо,все исправил…работает!!!

Максим Потапов

1 year ago


не помогает ничего, какие только пути не прописывал и полный и относительный, картинки в порядке все по папочкам лежат

Владиминр Фомин

8 months ago


3 ответов

enter image description here
Image is not showing in browser using the image tag where am i wrong?
i want to add image in web and i am unable to do it using in visual code i don’t know where from image to be added in the URL of image so anyone guide.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sign up </title>
</head>
<body>
  <div class="Header">
      <a href="/" class="LogoWrapper" >
      <img src="D:my-angular-projectssignup-formsrcimageSnap.jpg" alt="Scone O'Clock logo" />
      </a>
      <p class="Strap">Scones: the most resplendent of snacks </p>
   </div>

        <div class="IntroWrapper">
            <p class="IntroText">
              Occasionally maligned and misunderstood; the scone is a quintessentially British classic.
            </p>
         <div class="MoneyShot">
              <img class="MoneyShotImg" src="D:my-angular-projectssignup-formsrcimage1555932407.jpg" alt="Incredible scones" />
              <p class="ImageCaption">Incredible scones, picture from Wikipedia</p>
         </div>
       </div>
     <p>Recipe and serving suggestions follow.</p>
   <div class="Ingredients">
      <h3 class="SubHeader">
      Ingredients</h3>
      <ul>
     </ul>
    </div>
   <div class="HowToMake">
    <h3 class="SubHeader">Method</h3>
    <ol class="MethodWrapper">
    </ol>
   </div>
</body>

   

 </html>

rioV8's user avatar

rioV8

21.6k3 gold badges24 silver badges43 bronze badges

asked Jun 25, 2020 at 23:08

Tahir Shahzad's user avatar

the problem is that your file retrieves the image based on where the html file is somewhere and it does not check the entire computer hard drive.

So if you want the problem fixed you can start from the html files location basically. So if your html file is in the src folder your img tag shall be

<img src="image/1555932407.jpg">

else if you have your html file in the signup-form folder i shall work with this

<img src="src/image/1555932407.jpg">

Hopefully you found this useful otherwise just comment this post.

answered Jun 25, 2020 at 23:41

TimFredriksson's user avatar

Visual Studio Code automatically retrieves files from the root directory, so it lists all of the files for you — making it easier to implement images and other stuff. It’s one of the main reasons I use VSCode.

The image location depends on where your HTML file is. Use forward slashes when specifying folders/files, and use ../ to go up a directory.

answered Jun 26, 2020 at 0:44

Nanoo's user avatar

NanooNanoo

7827 silver badges16 bronze badges

Понравилась статья? Поделить с друзьями:
  • При загрузке игры выдает ошибку exe
  • При загрузке драйвера произошла ошибка
  • При загрузке высококачественной версии произошла ошибка что делать
  • При загрузке высококачественной версии произошла ошибка iphone что
  • При генерации ошибка пин кода