Images in asp...

Discussion in 'ASP General' started by Jack Turner, Feb 2, 2005.

  1. Jack Turner

    Jack Turner Guest

    Hi all,

    Sorry if its been asked in here before but...

    ....how would i go about having an asp page send an image to the browser?

    what i mean is instead of:
    <img src="image.jpg"/>

    I want:
    <img src="image.asp?image=2"/>

    Any idea's, pointers, url's would be appreciated, as google is firing
    blanks.

    Thanks in advance

    --
    Regards, Posting from:
    Jack Turner? ¤Sunny Ol' Wolverhampton
     
    Jack Turner, Feb 2, 2005
    #1
    1. Advertising

  2. Something like <img src="image.asp?image=2"/> would simply be using an ASP
    page as the source. Instead, write a method using Sub that will take a
    parameter and write the desired image. I don't know what the names of your
    image files are, but if they are image1.jpg, image2.jpg, imageX.jpg, etc.,
    you could write something like:

    <%
    Sub ImageFile(filename_suffix)
    Response.Write("<img src=" & Chr(34) & "image" & filename_suffix &
    ".jpg" & Chr(34) & " />")
    End Sub
    %>

    And then use the following:

    <%
    ImageFile "1"
    ImageFile "2"
    ImageFile "X"
    %>

    To give the following output:

    <img src="image1.jpg" />
    <img src="image2.jpg" />
    <img src="imageX.jpg" />

    You will probably want to modify this code to your desire, and maybe put it
    in a loop if you have a bunch of images like image1.jpg, image2.jpg,
    image3.jpg, etc. that you would like next to each other. I hope this helps.
    --
    Nathan Sokalski

    www.nathansokalski.com

    "Jack Turner" <Jack@jt3k(nospammy).co.uk> wrote in message
    news:f1XLd.5224$...
    > Hi all,
    >
    > Sorry if its been asked in here before but...
    >
    > ...how would i go about having an asp page send an image to the browser?
    >
    > what i mean is instead of:
    > <img src="image.jpg"/>
    >
    > I want:
    > <img src="image.asp?image=2"/>
    >
    > Any idea's, pointers, url's would be appreciated, as google is firing
    > blanks.
    >
    > Thanks in advance
    >
    > --
    > Regards, Posting from:
    > Jack Turner? ¤Sunny Ol' Wolverhampton
    >
     
    Nathan Sokalski, Feb 2, 2005
    #2
    1. Advertising

  3. Jack Turner

    Jack Turner Guest

    In a weird place they call a newsgroup, Nathan Sokalski woke up and
    posted news:% using
    as their email address:
    || Something like <img src="image.asp?image=2"/> would simply be using
    || an ASP page as the source.

    Thats what i want, i want it so i can prevent hotlinking asp-side.

    IE on the asp source it has to have a valid refering address, else it
    redirects the user to an error image.


    --
    Regards, Posting from:
    Jack Turner? ¤Sunny Ol' Wolverhampton
     
    Jack Turner, Feb 3, 2005
    #3
  4. Jack Turner

    Evertjan. Guest

    Jack Turner wrote on 03 feb 2005 in
    microsoft.public.inetserver.asp.general:

    > In a weird place they call a newsgroup, Nathan Sokalski woke up and
    > posted news:% using
    > as their email address:
    >|| Something like <img src="image.asp?image=2"/> would simply be using
    >|| an ASP page as the source.
    >
    > Thats what i want, i want it so i can prevent hotlinking asp-side.
    >
    > IE on the asp source it has to have a valid refering address, else it
    > redirects the user to an error image.


    Stream your image:

    <http://aspfaq.com/show.asp?id=2276>

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Feb 3, 2005
    #4
  5. Jack Turner

    Adrienne Guest

    Gazing into my crystal ball I observed "Jack Turner" <Jack@jt3k
    (nospammy).co.uk> writing in news:dtfMd.5950$8B3.1077
    @text.news.blueyonder.co.uk:

    > In a weird place they call a newsgroup, Nathan Sokalski woke up and
    > posted news:% using
    > as their email address:
    >|| Something like <img src="image.asp?image=2"/> would simply be using
    >|| an ASP page as the source.
    >
    > Thats what i want, i want it so i can prevent hotlinking asp-side.
    >
    > IE on the asp source it has to have a valid refering address, else it
    > redirects the user to an error image.
    >
    >


    <% if request.servervariables("HTTP_HOST") = "www.example.com" then %>
    <img src="yourimage.png" alt="Your image description" />
    <% else %>
    <img src="badimage.png" alt="Stop Thief!" />
    <% end if %>

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, Feb 4, 2005
    #5
  6. Jack Turner

    Evertjan. Guest

    Adrienne wrote on 04 feb 2005 in microsoft.public.inetserver.asp.general:

    > Gazing into my crystal ball I observed "Jack Turner" <Jack@jt3k
    > (nospammy).co.uk> writing in news:dtfMd.5950$8B3.1077
    > @text.news.blueyonder.co.uk:
    >
    >> In a weird place they call a newsgroup, Nathan Sokalski woke up and
    >> posted news:% using
    >> as their email address:
    >>|| Something like <img src="image.asp?image=2"/> would simply be using
    >>|| an ASP page as the source.
    >>
    >> Thats what i want, i want it so i can prevent hotlinking asp-side.
    >>
    >> IE on the asp source it has to have a valid refering address, else it
    >> redirects the user to an error image.
    >>
    >>

    >
    > <% if request.servervariables("HTTP_HOST") = "www.example.com" then %>
    > <img src="yourimage.png" alt="Your image description" />
    > <% else %>
    > <img src="badimage.png" alt="Stop Thief!" />
    > <% end if %>
    >


    This will not help you, as the path to the img is available clientside.

    The only solution is to stream the img as an asp page testing for
    referrer first.

    <http://aspfaq.com/show.asp?id=2276>



    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Feb 4, 2005
    #6
  7. Jack Turner

    Adrienne Guest

    Gazing into my crystal ball I observed "Evertjan."
    <> writing in news:Xns95F38FF45B686eejj99@
    194.109.133.29:

    > Adrienne wrote on 04 feb 2005 in microsoft.public.inetserver.asp.general:
    >
    >> Gazing into my crystal ball I observed "Jack Turner" <Jack@jt3k
    >> (nospammy).co.uk> writing in news:dtfMd.5950$8B3.1077
    >> @text.news.blueyonder.co.uk:
    >>
    >>> In a weird place they call a newsgroup, Nathan Sokalski woke up and
    >>> posted news:% using
    >>> as their email address:
    >>>|| Something like <img src="image.asp?image=2"/> would simply be using
    >>>|| an ASP page as the source.
    >>>
    >>> Thats what i want, i want it so i can prevent hotlinking asp-side.
    >>>
    >>> IE on the asp source it has to have a valid refering address, else it
    >>> redirects the user to an error image.
    >>>
    >>>

    >>
    >> <% if request.servervariables("HTTP_HOST") = "www.example.com" then %>
    >> <img src="yourimage.png" alt="Your image description" />
    >> <% else %>
    >> <img src="badimage.png" alt="Stop Thief!" />
    >> <% end if %>
    >>

    >
    > This will not help you, as the path to the img is available clientside.
    >
    > The only solution is to stream the img as an asp page testing for
    > referrer first.
    >
    ><http://aspfaq.com/show.asp?id=2276>
    >
    >
    >


    You're right. I have the flu... wasn't thinking

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, Feb 4, 2005
    #7
  8. Jack Turner

    Evertjan. Guest

    Adrienne wrote on 04 feb 2005 in microsoft.public.inetserver.asp.general:
    >><http://aspfaq.com/show.asp?id=2276>

    >
    > You're right. I have the flu... wasn't thinking


    Be well soon.

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Feb 4, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    923
    Eliyahu Goldin
    Jan 4, 2005
  2. Luis Esteban Valencia Muñoz
    Replies:
    0
    Views:
    800
    Luis Esteban Valencia Muñoz
    Jun 3, 2005
  3. wardemon

    Cache Images vs Static Images

    wardemon, Jun 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    678
    bruce barker
    Jun 14, 2007
  4. Keith Hughitt
    Replies:
    6
    Views:
    1,101
  5. Adrienne Boswell
    Replies:
    1
    Views:
    524
    dorayme
    Aug 4, 2009
Loading...

Share This Page