Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress Question for a new poster and WP coder

  • This topic is empty.
Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #114821
    zeech
    Member

    Hey @chrisburton I think I figured it out! Thanks!

    #114828
    chrisburton
    Participant

    @zeech You sure?

    #114835
    zeech
    Member

    @chrisburton – I believe so – I figured out how to attach and show the image in the correct DIV on the template. I can style the image with CSS.
    Here is my markup in my template:

    $attachments = attachments_get_attachments();
    $total_attachments = count($attachments);
    ?>
    0 ) : ?>

    $tmp_attachment_id = $attachments[$i];
    $tmp_post_id = get_post($tmp_attachment_id);
    $tmp_title = $tmp_post_id->post_title;
    $tmp_path_array = explode(“/”,$attachments[$i]);
    $tmp_array_length = sizeof($tmp_path_array)-1;
    $tmp_filename = $tmp_path_array[$tmp_array_length];
    $j=$i+1;
    ?>

    echo wp_get_attachment_image($attachments[$i], $size=’full’, $icon = true);
    ?>

    Here is the basic CSS for the image:
    .attachments-div {
    position: relative;
    float: right;
    width: 35%;
    }

    .attachments-div img {
    border:#000 solid 1px;
    float:left;
    }

    And now using this template I can allow the client to upload and attach an image to the right hand column.

    My PHP is limited, so not totally sure what all the code means on the PHP side, but it worked! Do you see any thing wrong with it?
    Thanks again @chrisburton

    zack

    #114848
    chrisburton
    Participant

    Depending on the dimensions for `$size=’full’`, you might want to replace ‘full’ with ‘thumbnail’. If they are already sized correctly that code should work.

    #114925
    zeech
    Member

    Yeah I saw that in the code, actually changed it to full from thumbnail – one quick question, is there a PHP call that I can add for a hyperlink? Say I want to use the images and have them link to a specific page? An example (excuse the funky CSS background color) is this page: using attachments to build the thumbs, but would like them to link to the proper case studies page: http://weir-tsus.com/attachments/

    If you have quick answer thanks! If not I have hassled you enough! Thanks again @chrisburton
    cheers
    zack

    #114941
    chrisburton
    Participant

    @zeech This is what I use:


    $attachments = attachments_get_attachments();
    $total_attachments = count( $attachments ); if( $total_attachments ) : ?>

    “>

    #115375
    zeech
    Member

    @chrisburton thank your for the code!
    I did a slight modification to this chunk:
    “>

    zeech
    Member

    Sorry not letting me post the code properly… Trying again:

    “>

    chrisburton
    Participant

    @zeech I don’t think that’s correct. I believe it should be:

    “>

    Posts
  • The forum ‘Back End’ is closed to new topics and replies.