• Hi,

    I want to use the <img src="images/image1.jpg /> code on my wordpress pages.

    not in backend but inside the “html wordpress post page” ( the one where you write the articles).

    because if it’s backend it will be like this right?

    <img src="<?php bloginfo('template_directory'); ?>/images/image1.jpg />

    I dont want to upload the images,(because they are already in my images folder). i want to get it directly in my images folder (no upload media stuff)

    because if i upload it, the src will be like this

    https://localhost/wordpress/wp-content/uploads/2012/10/image1.jpg

    is there any shortcut for this one?
    because i’m trying to upload hundreds of tiny images, and i already have my html code setup

    if i can just copy paste it into the “html publish page” that will be great!

    Thanks,
    Jeremi L.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Have you access to the directories of your website?

    Thread Starter jeremi_liwanag

    (@jeremi_liwanag)

    What do you mean access? I’m using WordPress locally for now. I’m using WAMP

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you create a directory within your theme, name it relevantly and put all your images in there? Then you can specify that directory in your URLs.

    Thread Starter jeremi_liwanag

    (@jeremi_liwanag)

    Yes, i think i already have created a folder inside my theme

    WordPress/wp-content/themes/myTheme/images/ (this is where my images at)

    So the img src will be like

    <img src="images/image1.jpg" /> right? but this one doesn’t work

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Try
    /wp-content/themes/yourThemeName/images/image1.jpg

    Thread Starter jeremi_liwanag

    (@jeremi_liwanag)

    Tried /wp-content/themes/yourThemeName/images/image1.jpg

    doesn’t work :`(

    i wonder if there’s a plugin that can do that

    instead of https://localhost/wordpress/wp-content/uploads/2012/10/image1.jpg

    it will accept

    images/image1.jpg

    i really need a help on this ..

    because i have a lot of mini icons that are in unordered list. do i have to upload them and copy paste the url one by one? that will take me at-least a day to complete it.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Did you try replacing yourThemeName with your actual theme name?

    Thread Starter jeremi_liwanag

    (@jeremi_liwanag)

    Yes i did,

    actually it’s like this

    /wp-content/themes/mysite/images/miniperson.jpg

    also tried this

    wp-content/themes/mysite/images/miniperson.jpg

    /mysite/images/miniperson.jpg

    mysite/images/miniperson.jpg

    /images/miniperson.jpg

    images/miniperson.jpg

    /wordpress/wp-content/uploads/2012/10/image1.jpg

    wordpress/wp-content/uploads/2012/10/image1.jpg

    /wp-content/uploads/2012/10/image1.jpg

    wp-content/uploads/2012/10/image1.jpg

    none of them seems to work

    I think this might be a bit overkill, but you could try using shortcode.

    Add this to your functions.php:

    // Create the shortcode
    function template_url( $atts, $content = null ) {
        return '<img src="'. get_template_directory_uri() .'/'. $content .'" alt="" />';
    }  
    
    // Add as shortcode
    add_shortcode("template", "template_url");

    To use it, you could simply type this in your WordPress visual editor:
    [template]images/image1.jpg[/template]

    Which would result as:
    <img src="https://yoursite.com/wp-content/themes/yourtheme/images/image1.jpg" alt="" />

    This isn’t tested though, so it may contain errors. But the basic should look like that. ??

    Thanks Xaliber. Great piece of code. It worked out smoothly.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Post/Page Image Src HTML not Visual’ is closed to new replies.