looking for solve my issue.
i do a edit on a laravel site, but i cant call back the site url (entity.toUrl) for add to the "img src" with a google favicon.
i need to change the "imageIconUrl" with the "toUrl"
actual situation:
<a target="_blank" class="entity-url" :href="entity.toUrl">
<img :src="entity.imageIconUrl" :alt="entity.title">
<span>#{{entity.toUrl}}</span>
</a>
i try to edit from:
<img :src="entity.imageIconUrl" :alt="entity.title">
to (removed : before src and change to entity.toUrl):
<img src="http://www.google.com/s2/favicons?domain=#{{entity.toUrl}}" :alt="entity.title">
or:
<img src="http://www.google.com/s2/favicons?domain={{$toUrl}}"
but now if i check on site the source of the favicon image i get back this url:
https://www.google.com/s2/favicons?domain={{entity.toUrl}}
and not
https://www.google.com/s2/favicons?domain=example.com
when i call it in the <span>#{{entity.toUrl}}</span> work but not in the img src
any suggestion for help me?
many thanks
Not sure I completely understand your scenario, but assuming entity
is a variable being passed on to your view from the controller, you may try the following:
<img src="http://www.google.com/s2/favicons?domain={{$entity->toUrl}}" :alt="entity.title">
note there is no "#" before the {{...}} and the variable should be prefixed with $.
If you want to use title from entity in the image alt, it should work in the same way:
<img src="http://www.google.com/s2/favicons?domain={{$entity->toUrl}}" alt="{{$entity->title}}">
Note that I am not an expert - just another newbie looking for solutions here. :)
good luck!
Related
I am trying to use the get_option() function in Wordpress to set the SRC of an image in a theme file. The file is index.php, and represents the homepage.
The current image code is:
<img class="outside-collage-image" <?php echo 'src="'.get_option('article-image-1').'"'; ?>>
However, the image doesn't display, and when I inspect it, it simply says src(unknown) where it should have the proper SRC
I have tried a myriad of fixes, including leaving the SRC out of the php area and simply calling the function, but it doesn't seem to work.
The oddest part is, if I put on the page <p><?php echo 'src="'.get_option('article-image-1').'"'; ?></p> to check the output, it outputs into the <p> the proper code: src="http://image-site.com/my-image.jpg" (obviously the link to the image is fake, but the point is, it's a valid link.)
Any idea what could be causing this?
You can try this to get the image article-image-1.jpg in your root.
<img class="outside-collage-image" src="<?php echo get_site_url().'/article-image-1.jpg'; ?>">
It turns out that I screwed up, and the above function works just fine. I was simply applying it to the wrong image, and didn't realize that until looking at it a day later, when it wasn't 1:30 AM and I wasn't so tired. Thanks to all that answered.
headdesk
I have img tags that have parameters as part of the url. These parameters are used for an ajax image crop. They look like this
<img src="/resize/45-800/files/myImage.jpeg" alt="Chania">
By adding /resize/45-800/ in front of the url
I am able to tell the ajax script to get that file from the files directory, and dump a cropped version into /resize/files/
My question is, is there a way to remove these parameters 45-800/, which can be different each time, for file reading purposes only, so that html will read for the image like this
<img src="/resize/files/myImage.jpeg" alt="Chania">
but the world will see the src still like this
<img src="/resize/45-800/files/myImage.jpeg" alt="Chania">
Is this possible using htaccess?
I know I could use a query string and just use the ajax script to read from the src like this
<img src="/resize/files/myImage.jpeg?params=45-800" alt="Chania">
I was just hoping for a prettier way. I don't really want to use the question mark '?'.
The /resize and /files will always be there every time.
Does anyone know of a way?
I just had an epiphany... I could just put the crop width and height parameters in data attributes instead of in the url... So this
<img src="/resize/files/myImage.jpeg" data-wh="45-800" alt="Chania">
Instead of this
<img src="/resize/45-800/files/myImage.jpeg" alt="Chania">
Then I can serve them from the resize/files/ directory for all images that have the resize parameter passed into the url; and I don't have to use an ugly query string.
"/resize/45-800/files/myImage.jpeg?ugly=45-800"
So I haven't tested this, but I think I found the legit answer to my original question. I know its possible as the people at the last job I worked at used to resize images based on src url params. Here is the link - http://sneak.co.nz/projects/img-resizing/
My plugin is already finished and working now 8/ This method looks a little nicer though, they walk you through the whole image resize process, and use image caching as well.
Hope this helps someone as much as it does me if it works! I'll leave a comment if I end up testing it out and it works well.
how can i set image url in page ?
In image you can see I have tried by three ways but it not work.
Images are located under image folder of active theme.
You have three image tags all pointing to different urls of which two appear malformed.
The middle image tag in your screenshot seems the most accurate but you may want to add a semicolon after the right paranthesis.
If all three files are supposed to refer to the same image, then replace the first and last image tags with the middle one.
Then if it still doesnt work then replace bloginfo('template_directory') with the actual location to the images relative to document root on the server but put the value in quotes. For example, if your images are in the subfolder images in folder imageset on your site, then you could use
"http://www.whatever.com/imageset/images" or "/imageset/images".
which results in the code:
<img src="<?php echo "/imageset/images"; ?>/images/banner1.jpg" alt="">
or even better:
<img src="/imageset/images/images/banner1.jpg" alt="">
Try as follows <img src="../images/banner1.jpg" alt="">
php newbie. echoing out links to product pages, the following code works fine:
<a href="<?php echo $rows[$product_buy];?>"<p>Click Here for Details</p></a>
but, would like to change text link "Click Here..." to an image of a button.
tried different ways, searched around, still haven't figured it out
You could simply style your link to look like a button (by giving it a class/id to make sure not all links are targeted) or you can put an img tag between the a tag.
<img src="path_to_img" alt="">
I am new to Symfony.
I created a layout page in which I have this :
<img src="images/header.jpg" width="790" height="228" alt="" />
but the image isn't displayed in the page when accessed from the browser.
I put the file header.jpg in the web/images/ folder.
I thought I could learn Symfony in a week while working on a small project. is it possible ?
Use slash at the beginning like
<img src="/images/header.jpg" width="790" height="228" alt="" />
You can also use image_tag (which is better for routing)
image_tag('/images/header.jpg', array('alt' => __("My image")))
In the array with parameters you can add all HTML attributes like width, height, alt etc.
P.S. IT's not easy to learn Symfony. You need much more time
If you don't want a fully PHP generated image tag but just want the correct path to your image, you can do :
<img src="<?php echo image_path('header.jpg'); ?>"> width="700" height="228" alt="" />
Notice that the path passed to image_path excludes the /images part as this is automatically determined and created for you by Symfony, all you need to supply is the path to the file relative to the image directory.
You can also get to your image directory a little more crudely using
sfConfig::get('sf_web_dir')."/images/path/to/your/image.jpg"
It should be noted that using image_tag has a much larger performance cost attached to it than using image_path as noted on thirtyseven's blog
Hope that helps :)