Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-06-22 11:02:20
- jades
- Member
- Registered: 2009-03-10
- Posts: 14
article image reference in css
i’d like to pick up an article image and drop this in as bg image in a specific page via css
i know i can specify the id in the css
so in css
background-image: url(images/1.jpg) would pick up the correct image.
and the user could change this image by uploading a new one at id=1. But what i’d like to do is have an article with – text, image and custom field and by using a different layout the image is collected via CSS rather than as an image placeholder in html
i know this isn’t going to work but illustrates what i am trying to do – override a class in a specific layout:
<txp:if_section name=“bgimage”>
<—override current background for this page—>
<style>
#background: {
background-image: url(<txp:article_image />)}
</style>
</txp:if_section>”>
i’m currently using my own static stylesheets rather then TXPs inbuilt editor.
thanks/lovely product
james
Offline
Re: article image reference in css
Various image plugins, including upm_image, smd_gallery, and my own soo_image, allow you to output the article image URL.
Code is topiary
Offline
Re: article image reference in css
Or to get article image URL without a plugin, this should work:
<txp:php>
$ai = article_image(array());
echo preg_replace('/.+src=(.+?)(\'|").+/', '$1$2', $ai);
</txp:php>
or as one line:
<txp:php>
echo preg_replace('/.+src=(.+?)(\'|").+/', '$1$2', article_image(array()));
</txp:php>
Last edited by jsoo (2009-06-22 18:10:35)
Code is topiary
Offline
#4 2009-06-22 12:09:19
- jades
- Member
- Registered: 2009-03-10
- Posts: 14
Re: article image reference in css
wow. quick response. thanks people
Offline
Pages: 1