Skip to main content
Bumped by Community user
Tweeted twitter.com/StackMagento/status/748842109239693312
added 1 character in body; edited tags; edited title
Source Link
7ochem
  • 7.6k
  • 16
  • 54
  • 82

Get URL of the static assetscontent folder (for backend)

Inside a block class which is being used to render a button in the admin panel, how to get the URL of the static assetscontent folder? Specifically, URL of the folder with images?

For example, in Company_Helloworld module an image for a custom button is located here:

app/code/Company/Helloworld/view/adminhtml/web/images/

Test 1

I tried this:

$url = $this->getViewFileUrl('Company_Helloworld::images/icon.png'); 

But it tries to retrieve the image from the Magento/backend theme:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/Company_Helloworld/images/icon.png

while the image is not there, image is actually in the module's folder:

app/code/Company/Helloworld/view/adminhtml/web/images/icon.png

Test 2

And this:

$url = $this->getViewFileUrl('images/icon.png'); 

But it also tries to retrieve the image from the Magento/backend theme, this time without module context:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/images/icon.png

Is there any way to put the image in the module and not in the backend theme?

Get URL of the static assets folder (for backend)

Inside a block class which is being used to render a button in the admin panel, how to get the URL of the static assets folder? Specifically, URL of the folder with images?

For example, in Company_Helloworld module an image for a custom button is located here:

app/code/Company/Helloworld/view/adminhtml/web/images/

Test 1

I tried this:

$url = $this->getViewFileUrl('Company_Helloworld::images/icon.png'); 

But it tries to retrieve the image from the Magento/backend theme:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/Company_Helloworld/images/icon.png

while the image is not there, image is actually in the module's folder:

app/code/Company/Helloworld/view/adminhtml/web/images/icon.png

Test 2

And this:

$url = $this->getViewFileUrl('images/icon.png'); 

But it also tries to retrieve the image from the Magento/backend theme, this time without module context:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/images/icon.png

Is there any way to put the image in the module and not in the backend theme?

Get URL of the static content folder (for backend)

Inside a block class which is being used to render a button in the admin panel, how to get the URL of the static content folder? Specifically, URL of the folder with images?

For example, in Company_Helloworld module an image for a custom button is located here:

app/code/Company/Helloworld/view/adminhtml/web/images/

Test 1

I tried this:

$url = $this->getViewFileUrl('Company_Helloworld::images/icon.png'); 

But it tries to retrieve the image from the Magento/backend theme:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/Company_Helloworld/images/icon.png

while the image is not there, image is actually in the module's folder:

app/code/Company/Helloworld/view/adminhtml/web/images/icon.png

Test 2

And this:

$url = $this->getViewFileUrl('images/icon.png'); 

But it also tries to retrieve the image from the Magento/backend theme, this time without module context:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/images/icon.png

Is there any way to put the image in the module and not in the backend theme?

I extended an example
Source Link
maginfortis
  • 491
  • 6
  • 16

Inside a block class which is being used to render a button in the admin panel, how to get the URL of the static assets folder? Specifically, URL of the folder with images?

For example, in Company_Helloworld module an image for a custom button is located here:

app/code/Company/Helloworld/view/adminhtml/web/images/

Test 1

HowI tried this:

$url = $this->getViewFileUrl('Company_Helloworld::images/icon.png'); 

But it tries to get URL of thatretrieve the image from the Magento/backend theme:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/Company_Helloworld/images/icon.png

while the image is not there, image is actually in the module's folder inside a block class:

app/code/Company/Helloworld/view/adminhtml/web/images/icon.png

Test 2

And this:

$url = $this->getViewFileUrl('images/icon.png'); 

But it also tries to retrieve the image from the Magento/backend theme, this time without module context:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/images/icon.png

Is there any way to put the image in the module and not in the backend theme?

Inside a block class which is being used to render a button in the admin panel, how to get the URL of the static assets folder? Specifically, URL of the folder with images?

For example, in Company_Helloworld module an image for a custom button is located here:

app/code/Company/Helloworld/view/adminhtml/web/images/

How to get URL of that folder inside a block class?

Inside a block class which is being used to render a button in the admin panel, how to get the URL of the static assets folder? Specifically, URL of the folder with images?

For example, in Company_Helloworld module an image for a custom button is located here:

app/code/Company/Helloworld/view/adminhtml/web/images/

Test 1

I tried this:

$url = $this->getViewFileUrl('Company_Helloworld::images/icon.png'); 

But it tries to retrieve the image from the Magento/backend theme:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/Company_Helloworld/images/icon.png

while the image is not there, image is actually in the module's folder:

app/code/Company/Helloworld/view/adminhtml/web/images/icon.png

Test 2

And this:

$url = $this->getViewFileUrl('images/icon.png'); 

But it also tries to retrieve the image from the Magento/backend theme, this time without module context:

http://example.com/pub/static/adminhtml/Magento/backend/en_US/images/icon.png

Is there any way to put the image in the module and not in the backend theme?

Source Link
maginfortis
  • 491
  • 6
  • 16

Get URL of the static assets folder (for backend)

Inside a block class which is being used to render a button in the admin panel, how to get the URL of the static assets folder? Specifically, URL of the folder with images?

For example, in Company_Helloworld module an image for a custom button is located here:

app/code/Company/Helloworld/view/adminhtml/web/images/

How to get URL of that folder inside a block class?