I have a number of images that need an empty alt attribute, that is alt="", using image_tag.
I tried the code in the accepted answer at image_tag - Is there a way to make the alt attr blank by default? but it results in <img alt> not <img alt="">.
Short of removing image_tag and using img can this be done?
Ok this is a non-issue. Alejandro's comment on the original question prompted me to check the source, I had previously only checked in devtools inspector.
The source is alt="" using the linked code, it's alt in Chrome's DOM.
Thanks for suggestions, sorry for any trouble.
Related
The image is rendered on my blog of website using following erb code
<a href="<%= article_url(article)%>">
<img src="<%= article.main_image_url%>" alt="<%= article.title%>" /</a>
The main image url is actually stored in cloudfront on the url
https://s3.ap-south-1.amazonaws.com/mywebsite-dev/uploads/article/main_image/100/wonderful_image__1_.jpg
A scaled down version of size 500 X 250 pixel is stored at location
https://s3.ap-south-1.amazonaws.com/mywebsite-dev/uploads/article/main_image/100/large_wonderful_image__1_.jpg
My model of the article only saves the main image url. However, while uploading the image to s3, I do create a scaled down version of the image and add 'large_' prefix. This can be seen in the above url examples.
As of now, my erb code, renders the main image on the webpage and I need to edit this code, so that it renders the scaled down image instead. Basically, I need to edit this
<img src="<%= article.main_image_url%>"
so that erb changes
(The urls below are changed to blank client website'
https://s3.ap-south-1.amazonaws.com/mywebsite-dev/uploads/article/main_image/100/wonderful_image__1_.jpg
to this
https://s3.ap-south-1.amazonaws.com/mywebsite-dev/uploads/article/main_image/100/large_wonderful_image__1_.jpg
May be I need to split the article url by '/', take out the last part and add 'large_' to it.
Thanks in advance for the help. I am quite new to ROR and more into python.
Regards
I figured it out.It may be not a clean solution but it worked for me as of now.
<img src="<%= article.main_image_url.rpartition('/').first+'/large_'+article.main_image_url.rpartition('/').last%>" alt="<%= article.title%>" />
Thanks to everyone
I want to link images on my index page, to their permalink page, but the tags don't seem to be working. It's not that the images are not linking to the correct place, they're simply not being rendered as links at all.
This is the code:
{block:Photo}
<article id="{PostID}" class="post photo">
**<img src="{PhotoURL-HighRes}" href="{Permalink}" alt="{PhotoAlt}"/>**
{block:IndexPage}
<div style="{block:ifShowPhotoCaption} display: none; {/block:ifShowPhotoCaption}" class="control">
{NoteCountWithLabel}
This should link the image on the index page to its permalink page, but it doesn't create a link at all, in the same way 'note count' label does, in the second block of code.
I've tried:
<img src="{PhotoURL-HighRes}"><a href="{Permalink}" alt="{PhotoAlt}"/>
Instead of the code I posted, but it makes no difference. I've also tried moving the {block:IndexPage} to before the {block:Photo} tag, but this doesn't work, and also has the effect of messing up the permalink page when I view it through the 'notes count' link.
My tumblr: http://ginnypig.tumblr.com/
Thanks in advance.
Fixed it.
The code needed to be:
<img src="{PhotoURL-HighRes}" alt="{PhotoAlt}"/>
As opposed to what I was using:
<img src="{PhotoURL-HighRes}" href="{Permalink}" alt="{PhotoAlt}"/>
I'm trying to implement redactor as a WYSIWYG editor with ruby on rails. Everything seems to be working fine except that when I edit text in the editor the html tags show up. This happens even when I use the html button on the toolbar.
So on the webpage the text appears something like this:
<p>Edited text here</p>
I haven't included any code because I'm not really sure where to begin looking with this so any help at all will be appreciated :)
when using a text editor you have to tell your rails app that the area is html safe.
This is (by default) not the case as people could attack your site by using a text box you have put into your app.
by declaring an area as html safe you should be able to use the html tags as you like.
be aware of the security risk for using this.
e.g.
<div class="description">
<%= #foo.foo_desc.html_safe%>
</div>
Hope this clears it up for you.
in your view try using raw before the text you are trying to show. For example
<%= raw #post.body %>
this will work out with the html tags and show the processed text only without the tags.
I am a new coder/web designer and i am trying to add a the youtube logo that when clicked confirm subscription to the users channel
i have a php file with the following coding within...
<div id="youtube">
<img src="/images/YouTube.png />
</div>
this links to confirm subscription and the image directory is correct
however the problem is that whenever i add this into the coding it stuffs everything up!
if you go to any page and right click and go 'inspect element' you will see that the like box for facebook has a box around it which has the room for the youtube picture link
but it doesnt work, as said, when i add it in everything just clumps up together and/or the menu clumps up and goes all weird
You had two problems by the looks of things. The first issue was your include filename was wrong and the second was that you missed the closing inverted comma "
This was on the img src= tag
Try to change your id to something else - like <div id="youtube-confirm">
The youtube id might be reserved in FB script and it messes up your and their stuff
I'm trying to open an image in new brrowser tab like this:
<a href="" target="_blank">
<img height="660px" width="420px"
src="<%= Url.Action("WebPageImage", "WPMManagement", new { id = actualId }) %>"
alt="bild mit webseiten version" />
</a>
I need to show just an image and nothing else (no styles etc.)
What about href? What do I need in it?
Change the href attribute to the URL of your image and you're good to go:
Click here to view the image
EDIT: If you're retrieving images from the database, then you'll need Url.Action rather than Url.Content. Check out this question for a similar discussion about retrieving images from a database.
EDIT #2: Updated the example code to use Url.Action rather than Url.Content